Merge "Developer guide for mso-openstack-adapters Issue-ID: SO-3154"
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
index 59c6bec..fa5c57f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
@@ -89,4 +89,23 @@
v3Auth.setScope(scope);
return v3Auth;
}
+
+ public final com.woorea.openstack.keystone.v3.model.Authentication getAuthenticationForV3(
+ CloudIdentity cloudIdentity) {
+ Identity identity = new Identity();
+ Password password = new Password();
+ User user = new User();
+ Domain userDomain = new Domain();
+ userDomain.setName(cloudIdentity.getUserDomainName());
+ user.setName(cloudIdentity.getMsoId());
+ user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
+ user.setDomain(userDomain);
+ password.setUser(user);
+ identity.setPassword(password);
+ identity.setMethods(Collections.singletonList("password"));
+ com.woorea.openstack.keystone.v3.model.Authentication v3Auth =
+ new com.woorea.openstack.keystone.v3.model.Authentication();
+ v3Auth.setIdentity(identity);
+ return v3Auth;
+ }
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
index 1690695..3564b8f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
@@ -107,7 +107,7 @@
return policy;
}
- protected String findEndpointURL(List<Service> serviceCatalog, String type, String region, String facing) {
+ public String findEndpointURL(List<Service> serviceCatalog, String type, String region, String facing) {
for (Service service : serviceCatalog) {
if (type.equals(service.getType())) {
for (Service.Endpoint endpoint : service.getEndpoints()) {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
index 63bc235..072ab5a 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
@@ -21,15 +21,29 @@
package org.onap.so.openstack.utils;
import java.util.Map;
+import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.openstack.beans.MsoTenant;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.utils.CryptoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.woorea.openstack.keystone.v3.model.Token;
+import com.woorea.openstack.base.client.OpenStackConnectException;
+import com.woorea.openstack.base.client.OpenStackResponseException;
+import com.woorea.openstack.keystone.v3.Keystone;
+import com.woorea.openstack.keystone.v3.api.TokensResource.Authenticate;
+import com.woorea.openstack.keystone.v3.model.Authentication;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity;
@Component
public class MsoKeystoneV3Utils extends MsoTenantUtils {
+ @Autowired
+ private AuthenticationMethodFactory authenticationMethodFactory;
+
@Override
public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
throws MsoException {
@@ -57,4 +71,22 @@
return cloudIdentity.getIdentityUrl();
}
+ public Token getKeystoneToken(CloudSite cloudSite) throws MsoException {
+ try {
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+
+ Keystone keystone = new Keystone(cloudIdentity.getIdentityUrl());
+
+ Authentication auth = authenticationMethodFactory.getAuthenticationForV3(cloudIdentity);
+
+ Authenticate authenticate = keystone.tokens().authenticate(auth);
+ return executeAndRecordOpenstackRequest(authenticate);
+
+ } catch (OpenStackResponseException e) {
+ throw keystoneErrorToMsoException(e, "TokenAuth");
+ } catch (OpenStackConnectException e) {
+ throw keystoneErrorToMsoException(e, "TokenAuth");
+ }
+ }
+
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java
index c5eeb34..968e786 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java
@@ -49,4 +49,6 @@
novaClient.token(keystone.getId());
return novaClient;
}
+
+
}
diff --git a/adapters/mso-cnf-adapter/pom.xml b/adapters/mso-cnf-adapter/pom.xml
index fb25157..0928da0 100644
--- a/adapters/mso-cnf-adapter/pom.xml
+++ b/adapters/mso-cnf-adapter/pom.xml
@@ -110,11 +110,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
- <!-- <dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
- </dependency> -->
+ </dependency>
<!-- <dependency>
<groupId>org.onap.so</groupId>
<artifactId>mso-requests-db</artifactId>
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/exceptions/ApplicationException.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/exceptions/ApplicationException.java
new file mode 100644
index 0000000..c950cf6
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/exceptions/ApplicationException.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.exceptions;
+
+import static org.onap.so.adapters.cnf.util.CNfAdapterUtil.marshal;
+import org.onap.so.adapters.cnf.model.ErrorResponse;
+import org.springframework.http.ResponseEntity;
+
+public class ApplicationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private int errorCode;
+
+ private String errorMsg;
+
+ public ApplicationException(int errorCode, String errorMsg) {
+ this.errorCode = errorCode;
+ this.errorMsg = errorMsg;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+ public ResponseEntity buildErrorResponse() {
+ String message;
+ try {
+ ErrorResponse err = new ErrorResponse(errorCode, errorMsg);
+ message = marshal(err);
+ } catch (ApplicationException e) {
+ return ResponseEntity.status(500).body("Internal Server Error");
+ }
+ return ResponseEntity.status(errorCode).body(message);
+ }
+}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/BpmnInstanceRequest.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/BpmnInstanceRequest.java
new file mode 100644
index 0000000..2e76d51
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/BpmnInstanceRequest.java
@@ -0,0 +1,87 @@
+package org.onap.so.adapters.cnf.model;
+
+import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(value = "true")
+public class BpmnInstanceRequest {
+
+ @JsonProperty(value = "modelInvariantId")
+ private String modelInvariantId;
+
+ @JsonProperty(value = "modelVersionId")
+ private String modelVersionId;
+
+ @JsonProperty(value = "k8sRBProfileName")
+ private String k8sRBProfileName;
+
+ @JsonProperty(value = "cloudRegionId")
+ private String cloudRegionId;
+
+ @JsonProperty(value = "vfModuleUUID")
+ private String vfModuleUUID;
+
+ @JsonProperty(value = "labels")
+ private Map<String, String> labels;
+
+ @JsonProperty(value = "overrideValues")
+ private Map<String, String> overrideValues;
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getK8sRBProfileName() {
+ return k8sRBProfileName;
+ }
+
+ public void setK8sRBProfileName(String k8sRBProfileName) {
+ this.k8sRBProfileName = k8sRBProfileName;
+ }
+
+ public String getCloudRegionId() {
+ return cloudRegionId;
+ }
+
+ public void setCloudRegionId(String cloudRegionId) {
+ this.cloudRegionId = cloudRegionId;
+ }
+
+ public String getVfModuleUUID() {
+ return vfModuleUUID;
+ }
+
+ public void setVfModuleUUID(String vfModuleUUID) {
+ this.vfModuleUUID = vfModuleUUID;
+ }
+
+ public Map<String, String> getLabels() {
+ return labels;
+ }
+
+ public void setLabels(Map<String, String> labels) {
+ this.labels = labels;
+ }
+
+ public Map<String, String> getOverrideValues() {
+ return overrideValues;
+ }
+
+ public void setOverrideValues(Map<String, String> overrideValues) {
+ this.overrideValues = overrideValues;
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/ErrorResponse.java
similarity index 97%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java
rename to adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/ErrorResponse.java
index 188349c..135adcc 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/ErrorResponse.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.model;
+package org.onap.so.adapters.cnf.model;
public class ErrorResponse {
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceEntity.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/MulticloudInstanceRequest.java
similarity index 84%
rename from adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceEntity.java
rename to adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/MulticloudInstanceRequest.java
index 04f2f9d..b1719cb 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceEntity.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/MulticloudInstanceRequest.java
@@ -5,7 +5,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(value = "true")
-public class InstanceEntity {
+public class MulticloudInstanceRequest {
@JsonProperty(value = "cloud-region")
private String cloudRegion;
@@ -25,6 +25,9 @@
@JsonProperty(value = "override-values")
private Map<String, String> overrideValues;
+ @JsonProperty(value = "release-name")
+ private String vfModuleUuid;
+
public String getCloudRegion() {
return cloudRegion;
}
@@ -73,4 +76,12 @@
this.overrideValues = overrideValues;
}
+ public String getVfModuleUuid() {
+ return vfModuleUuid;
+ }
+
+ public void setVfModuleUuid(String vfModuleUuid) {
+ this.vfModuleUuid = vfModuleUuid;
+ }
+
}
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 952edef..b6d50da 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,27 +1,39 @@
package org.onap.so.adapters.cnf.rest;
+import java.io.File;
+import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
+import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
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.InstanceEntity;
+import org.onap.so.adapters.cnf.model.MulticloudInstanceRequest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+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.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -32,14 +44,14 @@
private final CloseableHttpClient httpClient = HttpClients.createDefault();
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/healthcheck"}, method = RequestMethod.GET,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/healthcheck"}, method = RequestMethod.GET,
produces = "application/json")
public String healthCheck() throws Exception {
logger.info("health check called.");
// TODO
- HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/healthcheck");
+ 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());
@@ -47,7 +59,7 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition"}, method = RequestMethod.POST,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/v1/rb/definition"}, method = RequestMethod.POST,
produces = "application/json")
public String createRB(@RequestBody ResourceBundleEntity rB) throws Exception {
@@ -55,7 +67,7 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition");
+ HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/rb/definition");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
String requestBody = objectMapper.writeValueAsString(rB);
@@ -70,8 +82,8 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}"},
- method = RequestMethod.GET, produces = "application/json")
+ @RequestMapping(value = {"/api/cnf-adapter/v1/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 {
@@ -79,8 +91,7 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet(
- "https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/" + rbVersion);
+ HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
return EntityUtils.toString(response.getEntity());
@@ -88,7 +99,93 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/profile"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/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 {
+
+ logger.info("delete RB called.");
+
+ // 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);
+
+ 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/{rb-name}"}, method = RequestMethod.GET,
+ produces = "application/json")
+ public String getListOfRB(@PathVariable("rb-name") String rbName) throws Exception {
+
+ logger.info("getListOfRB called.");
+
+ // TODO
+ // Below URL should be changed as appropriate multicloud URL.
+ HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition/" + rbName);
+
+ 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.GET,
+ produces = "application/json")
+ public String getListOfRBWithoutUsingRBName() throws Exception {
+
+ logger.info("getListOfRBWithoutUsingRBName called.");
+
+ // TODO
+ // Below URL should be changed as appropriate multicloud URL.
+ HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/rb/definition");
+
+ 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/{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 {
+
+ logger.info("Upload Artifact For RB called.");
+
+ File convFile = new File(file.getOriginalFilename());
+ file.transferTo(convFile);
+ FileBody fileBody = new FileBody(convFile, ContentType.DEFAULT_BINARY);
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+ builder.addPart("file", fileBody);
+ HttpEntity entity = builder.build();
+
+ // 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");
+ post.setHeader("Content-Type", "multipart/form-data");
+ logger.info(String.valueOf(post));
+ post.setEntity(entity);
+
+ 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/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 {
@@ -97,8 +194,8 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/"
- + rbVersion + "/profile");
+ HttpPost post =
+ new HttpPost("http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(fE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -112,7 +209,7 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/profile/{pr-name}"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/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 {
@@ -121,8 +218,8 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/"
- + rbVersion + "/profile/" + prName);
+ HttpGet req = new HttpGet(
+ "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/profile/" + prName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -131,18 +228,130 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/instance"}, method = RequestMethod.POST,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/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 {
+
+ logger.info("getListOfProfile called.");
+
+ // 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");
+
+ 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/{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 {
+
+ logger.info("delete Profile called.");
+
+ // 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);
+
+ 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/{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,
+ @PathVariable("pr-name") String prName) throws Exception {
+
+ logger.info("Upload Artifact For Profile called.");
+
+ File convFile = new File(file.getOriginalFilename());
+ file.transferTo(convFile);
+ FileBody fileBody = new FileBody(convFile, ContentType.DEFAULT_BINARY);
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+ builder.addPart("file", fileBody);
+ HttpEntity entity = builder.build();
+
+ // 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/" + prName + "/content");
+ post.setHeader("Content-Type", "multipart/form-data");
+
+ logger.info(String.valueOf(post));
+ post.setEntity(entity);
+
+ 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"}, method = RequestMethod.POST,
produces = "application/json")
- public String createInstance(@RequestBody InstanceEntity iE) throws Exception {
+ 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.
- HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/instance");
+ HttpPut post = new HttpPut("http://172.17.0.2:31770/v1/instance/" + instanceId);
ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
String requestBody = objectMapper.writeValueAsString(iE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
post.setEntity(requestEntity);
@@ -155,14 +364,15 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/instance/{instID}"}, method = RequestMethod.GET,
+ @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("https://localhost:32780/api/multicloud-k8s/v1/v1/instance/" + instanceId);
+ HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/instance/" + instanceId);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -171,8 +381,62 @@
}
@ResponseBody
- @RequestMapping(
- value = {"/api/multicloud-k8s/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config"},
+ @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"},
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)
@@ -182,8 +446,8 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/definition/" + rbName + "/"
- + rbVersion + "/profile/" + prName + "/config");
+ HttpPost post = new HttpPost(
+ "http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/" + prName + "/config");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(cE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -198,7 +462,7 @@
@ResponseBody
@RequestMapping(value = {
- "/api/multicloud-k8s/v1/v1/definition/{rb-name}/{rb-version}/profile/{profile-name}/config/{cfg-name}"},
+ "/api/cnf-adapter/v1/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 {
@@ -207,8 +471,8 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/definition/" + rbName + "/"
- + rbVersion + "/profile/" + prName + "/config/" + cfgName);
+ HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion + "/profile/"
+ + prName + "/config/" + cfgName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -217,7 +481,79 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/connectivity-info"}, method = RequestMethod.POST,
+ @RequestMapping(value = {
+ "/api/cnf-adapter/v1/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,
+ @PathVariable("cfg-name") String cfgName) throws Exception {
+
+ logger.info("delete Configuration called.");
+
+ // TODO
+ // Below URL should be changed as appropriate multicloud URL.
+ HttpDelete req = new HttpDelete("http://172.17.0.2:31770/v1/definition/" + rbName + "/" + rbVersion
+ + "/profile/" + prName + "/config/" + cfgName);
+
+ 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/{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,
+ @PathVariable("cfg-name") String cfgName) throws Exception {
+
+ logger.info("update Configuration called.");
+
+ // 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/"
+ + prName + "/config/" + cfgName);
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBody = objectMapper.writeValueAsString(cE);
+ 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/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 {
+ logger.info("Tag Configuration called.");
+
+ // 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");
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBody = objectMapper.writeValueAsString(tag);
+ 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/connectivity-info"}, method = RequestMethod.POST,
produces = "application/json")
public String createConnectivityInfo(@RequestBody ConnectivityInfo cIE) throws Exception {
@@ -225,7 +561,7 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("https://localhost:32780/api/multicloud-k8s/v1/v1/connectivity-info");
+ HttpPost post = new HttpPost("http://172.17.0.2:31770/v1/connectivity-info");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(cIE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -239,7 +575,7 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/connectivity-info/{connname}"}, method = RequestMethod.GET,
+ @RequestMapping(value = {"/api/cnf-adapter/v1/v1/connectivity-info/{connname}"}, method = RequestMethod.GET,
produces = "application/json")
public String getConnectivityInfo(@PathVariable("connname") String connName) throws Exception {
@@ -247,7 +583,7 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/connectivity-info/" + connName);
+ HttpGet req = new HttpGet("http://172.17.0.2:31770/v1/connectivity-info/" + connName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -256,7 +592,25 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/v1/connectivity-info/{connname}"}, method = RequestMethod.DELETE,
+ produces = "application/json")
+ public String deleteConnectivityInfo(@PathVariable("connname") String connName) throws Exception {
+
+ logger.info("delete Connectivity Info called.");
+
+ // TODO
+ // Below URL should be changed as appropriate multicloud URL.
+ HttpDelete req = new HttpDelete("http://172.17.0.2:31770/v1/connectivity-info/" + connName);
+
+ 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/{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 {
@@ -265,8 +619,8 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpPost post = new HttpPost("http://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/"
- + rbVersion + "/config-template");
+ HttpPost post = new HttpPost(
+ "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template");
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(tE);
StringEntity requestEntity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
@@ -280,7 +634,7 @@
}
@ResponseBody
- @RequestMapping(value = {"/api/multicloud-k8s/v1/v1/rb/definition/{rb-name}/{rb-version}/config-template/{tname}"},
+ @RequestMapping(value = {"/api/cnf-adapter/v1/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 {
@@ -289,8 +643,8 @@
// TODO
// Below URL should be changed as appropriate multicloud URL.
- HttpGet req = new HttpGet("https://localhost:32780/api/multicloud-k8s/v1/v1/rb/definition/" + rbName + "/"
- + rbVersion + "/config-template/" + tName);
+ HttpGet req = new HttpGet(
+ "http://172.17.0.2:31770/v1/rb/definition/" + rbName + "/" + rbVersion + "/config-template/" + tName);
try (CloseableHttpResponse response = httpClient.execute(req)) {
logger.info("response:" + response.getEntity());
@@ -298,4 +652,83 @@
}
}
+ @ResponseBody
+ @RequestMapping(value = {"/api/cnf-adapter/v1/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 {
+
+ logger.info("deleteTemplate called.");
+
+ // 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);
+
+ 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/{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,
+ @PathVariable("tname") String tName) throws Exception {
+
+ logger.info("uploadTarFileForTemplate called.");
+
+ File convFile = new File(file.getOriginalFilename());
+ file.transferTo(convFile);
+ FileBody fileBody = new FileBody(convFile, ContentType.DEFAULT_BINARY);
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+ builder.addPart("file", fileBody);
+ HttpEntity entity = builder.build();
+
+ // 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/" + tName + "/content");
+ post.setHeader("Content-Type", "multipart/form-data");
+
+ logger.info(String.valueOf(post));
+ post.setEntity(entity);
+
+ 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/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,
+ @PathVariable("prName") String prName) throws Exception {
+ logger.info("rollbackConfiguration called.");
+
+ // 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");
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBody = objectMapper.writeValueAsString(rE);
+ 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());
+ }
+ }
+
}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/util/CNfAdapterUtil.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/util/CNfAdapterUtil.java
new file mode 100644
index 0000000..25e506c
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/util/CNfAdapterUtil.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import org.onap.so.adapters.cnf.exceptions.ApplicationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.onap.logging.filter.base.ErrorCode;
+import static org.onap.so.logger.LoggingAnchor.THREE;
+import static org.onap.so.logger.MessageEnum.RA_NS_EXC;
+
+public class CNfAdapterUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CNfAdapterUtil.class);
+
+ public static final int BAD_REQUEST = 400;
+
+ private static final String UNMARSHAL_FAIL_MSG = "Failed to unmarshal json";
+
+ private static final String MARSHAL_FAIL_MSG = "Failed to marshal object";
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ public static class StatusDesc {
+
+ public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful";
+
+ public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful";
+
+ public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful";
+
+ public static final String ACTIVATE_NSS_SUCCESS = "Activate nss " + "is successful";
+
+ public static final String DEACTIVATE_NSS_SUCCESS = "Deactivate nss " + "is successful";
+
+ public static final String QUERY_JOB_STATUS_FAILED = "Query job " + "status failed";
+
+ public static final String QUERY_JOB_STATUS_SUCCESS = "Query job " + "status is successful";
+
+ private StatusDesc() {
+
+ }
+ }
+
+ private CNfAdapterUtil() {
+
+ }
+
+ public static void assertObjectNotNull(Object object) throws ApplicationException {
+ if (null == object) {
+ LOGGER.error("Object is null.");
+ throw new ApplicationException(BAD_REQUEST, "An object is null.");
+ }
+ }
+
+ public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException {
+ try {
+ return MAPPER.readValue(jsonstr, type);
+ } catch (IOException e) {
+ LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ }
+ }
+
+ public static String marshal(Object srcObj) throws ApplicationException {
+ try {
+ return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(srcObj);
+ } catch (IOException e) {
+ LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), MARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(BAD_REQUEST, MARSHAL_FAIL_MSG);
+ }
+ }
+
+}
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
new file mode 100644
index 0000000..38a1091
--- /dev/null
+++ b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/CnfAdapterRestTest.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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
+import org.onap.so.adapters.cnf.rest.CnfAdapterRest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+public class CnfAdapterRestTest {
+
+ @InjectMocks
+ CnfAdapterRest cnfAdapterRest;
+
+ @Test
+ public void createInstanceTest() throws Exception {
+
+ Map<String, String> labels = new HashMap<String, String>();
+ labels.put("custom-label-1", "label1");
+ Map<String, String> overrideValues = new HashMap<String, String>();
+ labels.put("image.tag", "latest");
+ labels.put("dcae_collector_ip", "1.2.3.4");
+ BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest();
+ bpmnInstanceRequest.setCloudRegionId("v1");
+ bpmnInstanceRequest.setLabels(labels);
+ bpmnInstanceRequest.setModelInvariantId("krd");
+ bpmnInstanceRequest.setModelVersionId("p1");
+ bpmnInstanceRequest.setOverrideValues(overrideValues);
+ bpmnInstanceRequest.setVfModuleUUID("20200824");
+
+ String mockedResponse = "K8sRBProfileName is required";
+ String actualResponse = cnfAdapterRest.createInstance(bpmnInstanceRequest);
+ assertNotNull(actualResponse);
+ assertEquals(mockedResponse, actualResponse);
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml
index db79182..45fe77e 100644
--- a/adapters/mso-nssmf-adapter/pom.xml
+++ b/adapters/mso-nssmf-adapter/pom.xml
@@ -162,7 +162,6 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
- <version>1.18.2</version>
</dependency>
</dependencies>
</project>
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java
index cd011e6..83a09dc 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java
@@ -20,6 +20,7 @@
package org.onap.so.adapters.nssmf;
+
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java
new file mode 100644
index 0000000..6a59244
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.config;
+
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@Getter
+public class NssmfAdapterConfig {
+
+ @Value("${mso.infra.endpoint}")
+ private String infraEndpoint;
+
+ @Value("${mso.infra.auth}")
+ private String infraAuth;
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java
similarity index 98%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java
index 484f762..dcb5d61 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/RequestDbConfig.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf;
+package org.onap.so.adapters.nssmf.config;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java
similarity index 97%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java
index 1522ca9..dfb2b61 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/WebSecurityConfig.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/config/WebSecurityConfig.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf;
+package org.onap.so.adapters.nssmf.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java
new file mode 100644
index 0000000..e762bc0
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.consts;
+
+import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.ExecutorType;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.beans.nsmf.NetworkType;
+import java.util.HashMap;
+import java.util.Map;
+
+public class NssmfAdapterConsts {
+
+ public final static String ONAP_INTERNAL_TAG = "ONAP_internal";
+
+ public final static String CURRENT_INTERNAL_NSSMF_API_VERSION = "v1";
+
+ private static Map<String, NssmfUrlInfo> urlInfoMap = new HashMap<>();
+
+ private final static String EXTERNAL_CN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles";
+
+ private final static String EXTERNAL_TN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles";
+
+ private final static String EXTERNAL_AN_ALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles";
+
+ private final static String INTERNAL_ALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/allocate";
+
+ private final static String EXTERNAL_CN_DEALLOCATE_URL =
+ "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{sliceProfileId}";
+
+ private final static String EXTERNAL_TN_DEALLOCATE_URL =
+ "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{sliceProfileId}";
+
+ private final static String EXTERNAL_AN_DEALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String INTERNAL_DEALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deAllocate";
+
+ private final static String EXTERNAL_CN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/activation";
+
+ private final static String EXTERNAL_TN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/activation";
+
+ private final static String EXTERNAL_AN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/activations";
+
+ private final static String INTERNAL_ACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/activate";
+
+ private final static String EXTERNAL_CN_DEACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/deactivation";
+
+ private final static String EXTERNAL_TN_DEACTIVATE_URL =
+ "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/deactivation";
+
+ private final static String EXTERNAL_AN_DEACTIVATE_URL =
+ "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/deactivation";
+
+ private final static String INTERNAL_DEACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deActivate";
+
+ //
+ private final static String EXTERNAL_CN_TERMINATE_URL =
+ "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String EXTERNAL_TN_TERMINATE_URL =
+ "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String EXTERNAL_AN_TERMINATE_URL =
+ "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String INTERNAL_TERMINATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/terminate";
+
+ //
+ private final static String EXTERNAL_AN_MODIFY_URL =
+ "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String INTERNAL_MODIFY_URL = "/onap/so/infra/3gppservices/{apiVersion}/modify";
+
+ //
+ private final static String EXTERNAL_QUERY_JOB_STATUS =
+ "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}?responseId={responseId}";
+
+ private final static String INTERNAL_QUERY_SUB_NET_CAPABILITY =
+ "/onap/so/infra/3gppservices/{apiVersion}/subnetCapabilityQuery";
+
+ static {
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_AN_ALLOCATE_URL, HttpMethod.POST));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_TN_ALLOCATE_URL, HttpMethod.POST));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.POST));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ALLOCATE),
+ new NssmfUrlInfo(INTERNAL_ALLOCATE_URL, HttpMethod.POST));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_AN_DEALLOCATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_TN_DEALLOCATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_CN_DEALLOCATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(INTERNAL_DEALLOCATE_URL, HttpMethod.DELETE));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_AN_ACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_TN_ACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_CN_ACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ACTIVATE),
+ new NssmfUrlInfo(INTERNAL_ACTIVATE_URL, HttpMethod.PUT));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_AN_DEACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_TN_DEACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_CN_DEACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(INTERNAL_DEACTIVATE_URL, HttpMethod.PUT));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.TERMINATE),
+ new NssmfUrlInfo(EXTERNAL_AN_TERMINATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.TERMINATE),
+ new NssmfUrlInfo(EXTERNAL_TN_TERMINATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.TERMINATE),
+ new NssmfUrlInfo(EXTERNAL_CN_TERMINATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.TERMINATE),
+ new NssmfUrlInfo(INTERNAL_TERMINATE_URL, HttpMethod.DELETE));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.MODIFY),
+ new NssmfUrlInfo(EXTERNAL_AN_MODIFY_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.MODIFY),
+ new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.MODIFY),
+ new NssmfUrlInfo(INTERNAL_MODIFY_URL, HttpMethod.PUT));
+
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.QUERY_JOB_STATUS),
+ new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.QUERY_JOB_STATUS),
+ new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.QUERY_JOB_STATUS),
+ new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET));
+
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.QUERY_SUB_NET_CAPABILITY),
+ new NssmfUrlInfo(INTERNAL_QUERY_SUB_NET_CAPABILITY, HttpMethod.POST));
+ }
+
+ /**
+ * get nssmf url info from consts
+ *
+ * @param executorType {@link ExecutorType}
+ * @param networkType {@link NetworkType}
+ * @param actionType {@link ActionType}
+ * @return {@link NssmfUrlInfo}
+ */
+ public static NssmfUrlInfo getNssmfUrlInfo(ExecutorType executorType, NetworkType networkType,
+ ActionType actionType) {
+
+ return urlInfoMap.get(generateKey(executorType, networkType, actionType));
+ }
+
+ private static String generateKey(ExecutorType executorType, NetworkType networkType, ActionType actionType) {
+ if (ExecutorType.EXTERNAL.equals(executorType)) {
+ return executorType.name() + "_" + networkType.name() + "_" + actionType.name();
+ }
+ return executorType.name() + "_" + actionType.name();
+ }
+
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java
new file mode 100644
index 0000000..5360657
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java
@@ -0,0 +1,61 @@
+package org.onap.so.adapters.nssmf.controller;
+
+import org.onap.so.adapters.nssmf.service.NssmfManagerService;
+import org.onap.so.beans.nsmf.*;
+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.*;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+@RestController
+@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON})
+public class NssmfAdapterController {
+
+ private static final Logger logger = LoggerFactory.getLogger(NssmfAdapterController.class);
+
+ @Autowired
+ private NssmfManagerService nssmfManagerService;
+
+ @PostMapping(value = "/NSS/SliceProfiles")
+ public ResponseEntity allocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest) {
+ return nssmfManagerService.allocateNssi(nbiRequest);
+ }
+
+ @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}")
+ public ResponseEntity deAllocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("sliceProfileId") final String sliceProfileId) {
+ return nssmfManagerService.deAllocateNssi(nbiRequest, sliceProfileId);
+ }
+
+
+ @PostMapping(value = "/NSS/{snssai}/activation")
+ public ResponseEntity activateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("snssai") String snssai) {
+ return nssmfManagerService.activateNssi(nbiRequest, snssai);
+ }
+
+ @PostMapping(value = "/NSS/{snssai}/deactivation")
+ public ResponseEntity deactivateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("snssai") String snssai) {
+ return nssmfManagerService.deActivateNssi(nbiRequest, snssai);
+ }
+
+ @PostMapping(value = "/NSS/jobs/{jobId}")
+ public ResponseEntity queryJobStatus(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("jobId") String jobId) {
+ return nssmfManagerService.queryJobStatus(nbiRequest, jobId);
+ }
+
+ @PostMapping(value = "/NSS/NSSISelectionCapability")
+ public ResponseEntity queryNSSISelectionCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) {
+ return nssmfManagerService.queryNSSISelectionCapability(nbiRequest);
+ }
+
+ @PostMapping(value = "/NSS/subnetCapabilityQuery")
+ public ResponseEntity querySubnetCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) {
+ return nssmfManagerService.querySubnetCapability(nbiRequest);
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java
similarity index 97%
copy from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java
copy to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java
index 188349c..a8653f8 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/ErrorResponse.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.model;
+package org.onap.so.adapters.nssmf.entity;
public class ErrorResponse {
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java
similarity index 69%
copy from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java
copy to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java
index 8007075..af26264 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java
@@ -18,27 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.model;
+package org.onap.so.adapters.nssmf.entity;
-public class TokenResponse {
+import lombok.Data;
- private String accessToken;
+@Data
+public class NssmfInfo {
- private int expires;
+ private String url;
- public String getAccessToken() {
- return accessToken;
- }
+ private String ipAddress;
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
+ private String port;
- public int getExpires() {
- return expires;
- }
+ private String insecure;
- public void setExpires(int expires) {
- this.expires = expires;
- }
+ private String cacert;
+
+ private String userName;
+
+ private String password;
}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java
new file mode 100644
index 0000000..f55ff10
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java
@@ -0,0 +1,17 @@
+package org.onap.so.adapters.nssmf.entity;
+
+import lombok.Data;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+
+@Data
+public class NssmfUrlInfo {
+
+ private String url;
+
+ private HttpMethod httpMethod;
+
+ public NssmfUrlInfo(String url, HttpMethod httpMethod) {
+ this.url = url;
+ this.httpMethod = httpMethod;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java
similarity index 98%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java
index cc047e4..218867c 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestResponse.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.rest;
+package org.onap.so.adapters.nssmf.entity;
import java.util.Map;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java
similarity index 69%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java
index 3590c68..bfcb875 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenRequest.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java
@@ -18,8 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.model;
+package org.onap.so.adapters.nssmf.entity;
+import lombok.Data;
+
+@Data
public class TokenRequest {
private String grantType;
@@ -27,28 +30,4 @@
private String userName;
private String value;
-
- public String getGrantType() {
- return grantType;
- }
-
- public void setGrantType(String grantType) {
- this.grantType = grantType;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java
similarity index 75%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java
index 8007075..552612a 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/model/TokenResponse.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java
@@ -18,27 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.model;
+package org.onap.so.adapters.nssmf.entity;
+
+import lombok.Data;
+
+@Data
public class TokenResponse {
private String accessToken;
private int expires;
-
- public String getAccessToken() {
- return accessToken;
- }
-
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-
- public int getExpires() {
- return expires;
- }
-
- public void setExpires(int expires) {
- this.expires = expires;
- }
}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java
new file mode 100644
index 0000000..ed327fd
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.enums;
+
+public enum ActionType {
+ ALLOCATE,
+
+ DEALLOCATE,
+
+ CREATE,
+
+ TERMINATE,
+
+ ACTIVATE,
+
+ DEACTIVATE,
+
+ QUERY_JOB_STATUS,
+
+ MODIFY_BY_ID,
+
+ MODIFY,
+
+ QUERY_NSSI_SELECTION_CAPABILITY,
+
+ QUERY_SUB_NET_CAPABILITY
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java
new file mode 100644
index 0000000..a76a54c
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.enums;
+
+public enum ExecutorType {
+ INTERNAL, EXTERNAL
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java
similarity index 97%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java
index f6abd98..9271bb5 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/HttpMethod.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.rest;
+package org.onap.so.adapters.nssmf.enums;
public enum HttpMethod {
GET, POST, PUT, DELETE, PATCH;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java
similarity index 97%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java
index f2e651f..d5cc1df 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/JobStatus.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.rest;
+package org.onap.so.adapters.nssmf.enums;
import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java
new file mode 100644
index 0000000..420dfdc
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.enums;
+
+public enum SelectionType {
+ NSSMF,
+
+ NSMF
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java
index f63ba35..2461f5c 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java
@@ -20,7 +20,7 @@
package org.onap.so.adapters.nssmf.exceptions;
-import org.onap.so.adapters.nssmf.model.ErrorResponse;
+import org.onap.so.adapters.nssmf.entity.ErrorResponse;
import org.springframework.http.ResponseEntity;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java
index c737ba6..665b111 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java
@@ -22,6 +22,7 @@
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.aai.domain.yang.ServiceInstance;
public interface AaiServiceProvider {
@@ -29,4 +30,7 @@
EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId);
+ void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType,
+ String serviceInstanceId);
+
}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java
index 8cb47eb..3f2e5b2 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java
@@ -23,7 +23,9 @@
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,4 +65,12 @@
});
}
+
+ @Override
+ public void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType,
+ String serviceInstanceId) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,
+ serviceType, serviceInstanceId);
+ aaiClientProvider.getAaiClient().create(uri, nssiInstance);
+ }
}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java
new file mode 100644
index 0000000..54ef1e0
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.beans.nsmf.*;
+
+public interface NssmfManager {
+
+ RestResponse allocateNssi(NssmfAdapterNBIRequest nssmfRequest) throws ApplicationException;
+
+ RestResponse deAllocateNssi(NssmfAdapterNBIRequest nssmfRequest, String sliceId) throws ApplicationException;
+
+ RestResponse activateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException;
+
+ RestResponse deActivateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException;
+
+ RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException;
+
+ RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException;
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java
new file mode 100644
index 0000000..0b332af
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager;
+
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.ExecutorType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.external.ExternalAnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.external.ExternalCnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.internal.InternalAnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.internal.InternalCnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.internal.InternalTnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.*;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.NetworkType;
+import org.onap.so.beans.nsmf.ServiceInfo;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+
+public class NssmfManagerBuilder {
+
+ private BaseNssmfManager nssmfManger;
+
+ private RestUtil restUtil;
+
+ private ActionType actionType;
+
+ private ResourceOperationStatusRepository repository;
+
+ private ServiceInfo serviceInfo;
+
+ private NssmfAdapterConfig adapterConfig;
+
+ public NssmfManagerBuilder(EsrInfo esrInfo) throws ApplicationException {
+
+ ExecutorType executorType = getExecutorType(esrInfo);
+ NetworkType networkType = esrInfo.getNetworkType();
+
+ if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) {
+ this.nssmfManger = new InternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType);
+ return;
+ }
+
+ if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) {
+ this.nssmfManger = new InternalTnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType);
+ return;
+ }
+
+ if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) {
+ this.nssmfManger = new InternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType);
+ return;
+ }
+
+ if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) {
+ this.nssmfManger = new ExternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
+ .setInitStatus("deactivated");
+ return;
+ }
+
+ if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) {
+ this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
+ .setInitStatus("activated");
+ return;
+ }
+
+ throw new ApplicationException(404, "invalid domain and simulator");
+ }
+
+ private ExecutorType getExecutorType(EsrInfo esrInfo) {
+ if (NssmfAdapterConsts.ONAP_INTERNAL_TAG.equals(esrInfo.getVendor())) {
+ return ExecutorType.INTERNAL;
+ }
+ return ExecutorType.EXTERNAL;
+ }
+
+ public NssmfManagerBuilder setRestUtil(RestUtil restUtil) {
+ this.restUtil = restUtil;
+ return this;
+ }
+
+ public NssmfManagerBuilder setActionType(ActionType actionType) {
+ this.actionType = actionType;
+ return this;
+ }
+
+ public NssmfManagerBuilder setRepository(ResourceOperationStatusRepository repository) {
+ this.repository = repository;
+ return this;
+ }
+
+ public NssmfManagerBuilder setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ return this;
+ }
+
+ public NssmfManagerBuilder setAdapterConfig(NssmfAdapterConfig adapterConfig) {
+ this.adapterConfig = adapterConfig;
+ return this;
+ }
+
+ public NssmfManager build() {
+ return this.nssmfManger.setRestUtil(restUtil).setAdapterConfig(adapterConfig).setRepository(repository)
+ .setActionType(actionType).setServiceInfo(serviceInfo);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
new file mode 100644
index 0000000..185dfaf
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
@@ -0,0 +1,273 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl;
+
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo;
+import org.onap.so.adapters.nssmf.enums.*;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.manager.NssmfManager;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.domain.Example;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ALLOCATE_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.MODIFY_NSS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public abstract class BaseNssmfManager implements NssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(BaseNssmfManager.class);
+
+ protected RestUtil restUtil;
+
+ protected ResourceOperationStatusRepository repository;
+
+ protected NssmfAdapterConfig adapterConfig;
+
+ protected ActionType actionType;
+
+ protected EsrInfo esrInfo;
+
+ protected String nssmfUrl;
+
+ protected HttpMethod httpMethod;
+
+ protected String initStatus;
+
+ protected ServiceInfo serviceInfo;
+
+ protected RestResponse restResponse;
+
+ private ExecutorType executorType = ExecutorType.INTERNAL;
+
+ private Map<String, String> params = new HashMap<>(); // request params
+
+ @Override
+ public RestResponse allocateNssi(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+
+ this.params.clear();
+ this.urlHandler();
+ String requestBody = wrapAllocateReqBody(nbiRequest);
+
+ this.restResponse = sendRequest(requestBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ protected abstract String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException {
+ this.params.clear();
+ this.urlHandler();
+ String requestBody = wrapModifyReqBody(modifyRequest);
+
+ this.restResponse = sendRequest(requestBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ protected abstract String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ public RestResponse deAllocateNssi(NssmfAdapterNBIRequest nbiRequest, String sliceId) throws ApplicationException {
+ this.params.clear();
+ this.params.put("sliceProfileId", sliceId);
+
+ this.urlHandler();
+
+ String reqBody = wrapDeAllocateReqBody(nbiRequest.getDeAllocateNssi());
+
+ this.restResponse = sendRequest(reqBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ protected abstract String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException;
+
+ protected abstract String wrapReqBody(Object object) throws ApplicationException;
+
+ @Override
+ public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException {
+ this.params.clear();
+ this.params.put("snssai", snssai);
+
+ this.urlHandler();
+
+ String reqBody = wrapActDeActReqBody(nbiRequest.getActDeActNssi());
+
+ this.restResponse = sendRequest(reqBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ @Override
+ public RestResponse deActivateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException {
+ return activateNssi(nbiRequest, snssai);
+ }
+
+ protected abstract String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException;
+
+ @Override
+ public RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException {
+ this.params.clear();
+ this.params.put("jobId", jobId);
+ this.params.put("responseId", jobReq.getResponseId());
+ this.urlHandler();
+
+ /**
+ * find by jobId and nsiId jobId -> OperationId nsiId -> ServiceId serviceUuid -> resourceTemplateUUID
+ */
+ ResourceOperationStatus status =
+ getOperationStatus(serviceInfo.getNsiId(), jobId, serviceInfo.getServiceUuid());
+
+ this.restResponse = doQueryJobStatus(status);
+
+ afterQueryJobStatus(status);
+ return restResponse;
+ }
+
+ protected abstract RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException;
+
+
+ protected abstract void afterQueryJobStatus(ResourceOperationStatus status);
+
+ private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) {
+
+ ResourceOperationStatus status = new ResourceOperationStatus(nsiId, jobId, serviceUuid);
+
+ Optional<ResourceOperationStatus> optional = repository.findOne(Example.of(status));
+
+ return optional.orElse(null);
+ }
+
+ @Override
+ public RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ SelectionType res = doQueryNSSISelectionCapability();
+ HashMap<String, String> hashMap = new HashMap<>();
+ hashMap.put("selection", res.name());
+ RestResponse restResponse = new RestResponse();
+ restResponse.setStatus(200);
+ restResponse.setResponseContent(marshal(hashMap));
+ return restResponse;
+ }
+
+ protected abstract SelectionType doQueryNSSISelectionCapability();
+
+ @Override
+ public RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ this.params.clear();
+ this.urlHandler();
+
+ return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery());
+ }
+
+ protected abstract RestResponse doQuerySubnetCapability(String req) throws ApplicationException;
+
+ /**
+ * send request to nssmf
+ *
+ * @param content request body
+ * @return response
+ * @throws ApplicationException
+ */
+ protected abstract RestResponse sendRequest(String content) throws ApplicationException;
+
+ /**
+ * handle the url before request to nssmf, include get the nssmf request url, replace the path variable
+ */
+ private void urlHandler() {
+ NssmfUrlInfo nssmfUrlInfo =
+ NssmfAdapterConsts.getNssmfUrlInfo(this.executorType, this.esrInfo.getNetworkType(), actionType);
+ this.nssmfUrl = nssmfUrlInfo.getUrl();
+ this.httpMethod = nssmfUrlInfo.getHttpMethod();
+ this.nssmfUrl = nssmfUrl.replaceAll("\\{apiVersion}", getApiVersion());
+ this.params.forEach((k, v) -> this.nssmfUrl = this.nssmfUrl.replaceAll("\\{" + k + "}", v));
+ }
+
+ /**
+ * after request
+ */
+ protected abstract void afterRequest() throws ApplicationException;
+
+ protected abstract String getApiVersion();
+
+ public RestUtil getRestUtil() {
+ return restUtil;
+ }
+
+ public BaseNssmfManager setEsrInfo(EsrInfo esrInfo) {
+ this.esrInfo = esrInfo;
+ return this;
+ }
+
+ public BaseNssmfManager setExecutorType(ExecutorType executorType) {
+ this.executorType = executorType;
+ return this;
+ }
+
+ public BaseNssmfManager setRestUtil(RestUtil restUtil) {
+ this.restUtil = restUtil;
+ return this;
+ }
+
+ public BaseNssmfManager setActionType(ActionType actionType) {
+ this.actionType = actionType;
+ return this;
+ }
+
+ public BaseNssmfManager setRepository(ResourceOperationStatusRepository repository) {
+ this.repository = repository;
+ return this;
+ }
+
+ public BaseNssmfManager setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ return this;
+ }
+
+ public BaseNssmfManager setInitStatus(String initStatus) {
+ this.initStatus = initStatus;
+ return this;
+ }
+
+ public BaseNssmfManager setAdapterConfig(NssmfAdapterConfig adapterConfig) {
+ this.adapterConfig = adapterConfig;
+ return this;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
new file mode 100644
index 0000000..f6584da
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
@@ -0,0 +1,201 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl;
+
+import org.apache.http.Header;
+import org.apache.http.message.BasicHeader;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.JobStatus;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static java.lang.String.valueOf;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.*;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.*;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+
+public abstract class ExternalNssmfManager extends BaseNssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExternalNssmfManager.class);
+
+ @Override
+ protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapExtAllocateReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapModifyReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ return doWrapDeAllocateReqBody(deAllocateNssi);
+ }
+
+ protected abstract String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException;
+
+ @Override
+ protected void afterQueryJobStatus(ResourceOperationStatus status) {
+ if (Integer.parseInt(status.getProgress()) == 100) {
+
+ ServiceInstance nssiInstance = new ServiceInstance();
+ nssiInstance.setServiceInstanceId(serviceInfo.getNssiId());
+ nssiInstance.setServiceInstanceName(serviceInfo.getNssiName());
+ nssiInstance.setServiceType(serviceInfo.getSST());
+
+ nssiInstance.setOrchestrationStatus(initStatus);
+ nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid());
+ nssiInstance.setModelVersionId(serviceInfo.getServiceUuid());
+ nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList());
+ nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType());
+ nssiInstance.setServiceRole("nssi");
+
+ restUtil.createServiceInstance(nssiInstance, serviceInfo);
+ }
+ }
+
+
+
+ @Override
+ protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException {
+ return marshal(actDeActNssi);
+ }
+
+ protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException {
+ return doResponseStatus(status);
+ }
+
+ private RestResponse doResponseStatus(ResourceOperationStatus status) throws ApplicationException {
+ RestResponse restResponse = sendRequest(null);
+ ResponseDescriptor rspDesc =
+ unMarshal(restResponse.getResponseContent(), JobStatusResponse.class).getResponseDescriptor();
+ updateRequestDbJobStatus(rspDesc, status, restResponse);
+ return restResponse;
+ }
+
+ @Override
+ protected String wrapReqBody(Object object) throws ApplicationException {
+ return marshal(object);
+ }
+
+ @Override
+ protected RestResponse sendRequest(String content) throws ApplicationException {
+ return sendExternalRequest(content);
+ }
+
+ protected void createStatus(JobStatus jobStatus) throws ApplicationException {
+ if (valueOf(restResponse.getStatus()).startsWith("2")) {
+ logger.info("save segment and operaton info -> begin");
+ NssiResponse response = unMarshal(restResponse.getResponseContent(), NssiResponse.class);
+ ResourceOperationStatus status = new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(),
+ serviceInfo.getServiceUuid());
+ status.setResourceInstanceID(response.getNssiId());
+
+ updateDbStatus(status, restResponse.getStatus(), jobStatus, NssmfAdapterUtil.getStatusDesc(actionType));
+ logger.info("save segment and operaton info -> end");
+ }
+ }
+
+ @Override
+ protected String getApiVersion() {
+ return "v1";
+ }
+
+
+ // external
+ protected RestResponse sendExternalRequest(String content) throws ApplicationException {
+ NssmfInfo nssmfInfo = restUtil.getNssmfHost(esrInfo);
+ Header header = new BasicHeader("X-Auth-Token", restUtil.getToken(nssmfInfo));
+ String nssmfUrl = nssmfInfo.getUrl() + this.nssmfUrl;
+ return restUtil.send(nssmfUrl, this.httpMethod, content, header);
+ }
+
+ private void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp)
+ throws ApplicationException {
+
+ switch (fromString(rspDesc.getStatus())) {
+ case STARTED:
+ updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS);
+ break;
+ case PROCESSING:
+ updateDbStatus(status, rsp.getStatus(), PROCESSING, QUERY_JOB_STATUS_SUCCESS);
+ break;
+ case FINISHED:
+ if (rspDesc.getProgress() == 100) {
+ updateDbStatus(status, rsp.getStatus(), FINISHED, QUERY_JOB_STATUS_SUCCESS);
+ }
+ break;
+ case ERROR:
+ updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED);
+ throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED);
+ }
+ }
+
+ protected void updateDbStatus(ResourceOperationStatus status, int rspStatus, JobStatus jobStatus,
+ String description) {
+ status.setErrorCode(valueOf(rspStatus));
+ status.setStatus(jobStatus.toString());
+ status.setStatusDescription(description);
+ logger.info("Updating DB status");
+ repository.save(status);
+ logger.info("Updating successful");
+ }
+
+ @Override
+ protected RestResponse doQuerySubnetCapability(String req) throws ApplicationException {
+ RestResponse response = new RestResponse();
+ response.setStatus(200);
+ response.setResponseContent(null);
+ return response;
+ }
+
+ /**
+ * after request, if response code is 2XX, continue handle, else return
+ */
+ @Override
+ protected void afterRequest() throws ApplicationException {
+ if (valueOf(restResponse.getStatus()).startsWith("2")) {
+ doAfterRequest();
+ }
+ }
+
+
+ protected void doAfterRequest() throws ApplicationException {
+ //
+ NssiResponse response = unMarshal(restResponse.getResponseContent(), NssiResponse.class);
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(), serviceInfo.getServiceUuid());
+ status.setResourceInstanceID(response.getNssiId());
+
+ updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType));
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
new file mode 100644
index 0000000..a945823
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl;
+
+import org.apache.http.Header;
+import org.apache.http.message.BasicHeader;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.JobStatus;
+import org.onap.so.adapters.nssmf.enums.SelectionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.PROCESSING;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public abstract class InternalNssmfManager extends BaseNssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(InternalNssmfManager.class);
+
+ @Override
+ protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapAllocateReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected String wrapReqBody(Object object) throws ApplicationException {
+ NssmfRequest nssmfRequest = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), object);
+ return marshal(nssmfRequest);
+ }
+
+
+ @Override
+ protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException {
+
+ return wrapReqBody(actDeActNssi);
+ }
+
+
+ @Override
+ protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ return wrapReqBody(deAllocateNssi);
+ }
+
+
+ @Override
+ protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException {
+ return responseDBStatus(status);
+ }
+
+ private RestResponse responseDBStatus(ResourceOperationStatus status) throws ApplicationException {
+ ResponseDescriptor descriptor = new ResponseDescriptor();
+ if (status == null) {
+ descriptor.setProgress(0);
+ descriptor.setStatus(PROCESSING.name());
+ descriptor.setStatusDescription("Initiating Nssi Instance");
+ return restUtil.createResponse(200, marshal(descriptor));
+ }
+ descriptor.setStatus(status.getStatus());
+ descriptor.setStatusDescription(status.getStatusDescription());
+ descriptor.setProgress(Integer.parseInt(status.getProgress()));
+ // descriptor.setResponseId(status.getOperationId());
+ return restUtil.createResponse(200, marshal(descriptor));
+ }
+
+ @Override
+ protected RestResponse sendRequest(String content) {
+ return sendInternalRequest(content);
+ }
+
+ @Override
+ protected void afterRequest() {
+ //
+ }
+
+ @Override
+ protected void afterQueryJobStatus(ResourceOperationStatus status) {
+ // internal
+ }
+
+ // internal
+ private RestResponse sendInternalRequest(String content) {
+ Header header = new BasicHeader("X-Auth-Token", adapterConfig.getInfraAuth());
+ this.nssmfUrl = adapterConfig.getInfraEndpoint() + this.nssmfUrl;
+ return restUtil.send(this.nssmfUrl, this.httpMethod, content, header);
+ }
+
+ @Override
+ protected String getApiVersion() {
+ return NssmfAdapterConsts.CURRENT_INTERNAL_NSSMF_API_VERSION;
+ }
+
+
+ @Override
+ protected SelectionType doQueryNSSISelectionCapability() {
+ return SelectionType.NSSMF;
+ }
+
+ @Override
+ protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapModifyReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected RestResponse doQuerySubnetCapability(String req) throws ApplicationException {
+ // handler
+ return sendRequest(req);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java
new file mode 100644
index 0000000..e244a85
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl.external;
+
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.JobStatus;
+import org.onap.so.adapters.nssmf.enums.SelectionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager;
+import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil;
+import org.onap.so.beans.nsmf.DeAllocateNssi;
+import org.onap.so.beans.nsmf.NssiResponse;
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.HashMap;
+import java.util.Map;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+
+
+public class ExternalAnNssmfManager extends ExternalNssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExternalAnNssmfManager.class);
+
+ @Override
+ protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return marshal(nbiRequest.getAllocateAnNssi().getSliceProfile());
+ }
+
+ @Override
+ protected void doAfterRequest() throws ApplicationException {
+ if (ActionType.ALLOCATE.equals(actionType) || ActionType.DEALLOCATE.equals(actionType)) {
+ @SuppressWarnings("unchecked")
+ Map<String, String> response = unMarshal(restResponse.getResponseContent(), Map.class);
+
+ String nssiId = response.get("nSSId");
+
+ NssiResponse resp = new NssiResponse();
+ resp.setJobId(nssiId);
+ resp.setNssiId(nssiId);
+
+ RestResponse returnRsp = new RestResponse();
+
+ returnRsp.setStatus(202);
+ returnRsp.setResponseContent(marshal(resp));
+ restResponse = returnRsp;
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(serviceInfo.getNsiId(), nssiId, serviceInfo.getServiceUuid());
+ status.setResourceInstanceID(nssiId);
+
+ updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED,
+ NssmfAdapterUtil.getStatusDesc(actionType));
+ }
+ // todo
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ // TODO
+ return null;
+ }
+
+ @Override
+ protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ Map<String, String> request = new HashMap<>();
+ request.put("nSSId", deAllocateNssi.getNssiId());
+ return marshal(request);
+ }
+
+
+ @Override
+ public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException {
+ // TODO
+ return null;
+ }
+
+ @Override
+ protected SelectionType doQueryNSSISelectionCapability() {
+ return SelectionType.NSSMF;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java
new file mode 100644
index 0000000..fb76adc
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl.external;
+
+import org.onap.so.adapters.nssmf.enums.SelectionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager;
+import org.onap.so.beans.nsmf.DeAllocateNssi;
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class ExternalCnNssmfManager extends ExternalNssmfManager {
+
+ @Override
+ protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return marshal(nbiRequest.getAllocateCnNssi());
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return marshal(nbiRequest.getAllocateCnNssi());
+ }
+
+ @Override
+ protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ return marshal(deAllocateNssi);
+ }
+
+ @Override
+ protected SelectionType doQueryNSSISelectionCapability() {
+
+ return SelectionType.NSMF;
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java
new file mode 100644
index 0000000..dc65283
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl.internal;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager;
+import org.onap.so.beans.nsmf.*;
+import java.util.HashMap;
+import java.util.Map;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+
+public class InternalAnNssmfManager extends InternalNssmfManager {
+
+ @Override
+ protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ NssmfRequest request =
+ new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateAnNssi());
+ request.setName(nbiRequest.getAllocateAnNssi().getNssiName());
+ return marshal(request);
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ AllocateAnNssi allocateAnNssi = nbiRequest.getAllocateAnNssi();
+ AnSliceProfile sliceProfile = allocateAnNssi.getSliceProfile();
+ Map<String, Object> additional = new HashMap<>();
+ additional.put("modifyAction", "allocate");
+ additional.put("snssaiList", sliceProfile.getSNSSAIList());
+ additional.put("sliceProfileId", sliceProfile.getSliceProfileId());
+ additional.put("nsiInfo", allocateAnNssi.getNsiInfo());
+ additional.put("scriptName", allocateAnNssi.getScriptName());
+ NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional);
+ return marshal(request);
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java
new file mode 100644
index 0000000..4a93b30
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl.internal;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager;
+import org.onap.so.beans.nsmf.*;
+import java.util.HashMap;
+import java.util.Map;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class InternalCnNssmfManager extends InternalNssmfManager {
+
+ @Override
+ protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+
+ NssmfRequest request =
+ new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateCnNssi());
+ request.setName(nbiRequest.getAllocateCnNssi().getNssiName());
+ return marshal(request);
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ AllocateCnNssi allocateCnNssi = nbiRequest.getAllocateCnNssi();
+ CnSliceProfile cnSliceProfile = allocateCnNssi.getSliceProfile();
+ Map<String, Object> additional = new HashMap<>();
+ additional.put("modifyAction", "allocate");
+ additional.put("nsiInfo", allocateCnNssi.getNsiInfo());
+ additional.put("scriptName", allocateCnNssi.getScriptName());
+ additional.put("snssaiList", cnSliceProfile.getSnssaiList());
+ additional.put("sliceProfileId", cnSliceProfile.getSliceProfileId());
+
+ NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional);
+ return marshal(request);
+ }
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java
new file mode 100644
index 0000000..8bfbd55
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.manager.impl.internal;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager;
+import org.onap.so.beans.nsmf.*;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class InternalTnNssmfManager extends InternalNssmfManager {
+
+ @Override
+ protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+
+ return marshal(new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(),
+ nbiRequest.getAllocateTnNssi()));
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ // TODO
+ return null;
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java
index d8e1e36..4fdcbf1 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfAdapterRest.java
@@ -20,6 +20,7 @@
package org.onap.so.adapters.nssmf.rest;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
import org.onap.so.beans.nsmf.JobStatusRequest;
import org.onap.so.beans.nsmf.NssiActDeActRequest;
@@ -43,6 +44,7 @@
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.assertObjectNotNull;
+@Deprecated
@Controller
@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON})
public class NssmfAdapterRest {
@@ -52,17 +54,6 @@
@Autowired
private NssmfManager nssmfMgr;
- @PostMapping(value = "/NSS/SliceProfiles")
- public ResponseEntity allocateNssi(@RequestBody NssiAllocateRequest allocate) {
- try {
- logger.info("Nssmi allocate request is invoked");
- assertObjectNotNull(allocate);
- RestResponse rsp = getNssmfMgr().allocateNssi(allocate);
- return buildResponse(rsp);
- } catch (ApplicationException e) {
- return e.buildErrorResponse();
- }
- }
@PostMapping(value = "/NSS/nssi")
public ResponseEntity createNssi(@RequestBody NssiCreateRequest create) {
@@ -76,19 +67,6 @@
}
}
- @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}")
- public ResponseEntity deAllocateNssi(@RequestBody NssiDeAllocateRequest deAllocate,
- @PathVariable("sliceProfileId") final String sliceId) {
- try {
- logger.info("Nssmf deallocate request is invoked");
- assertObjectNotNull(deAllocate);
- RestResponse rsp = getNssmfMgr().deAllocateNssi(deAllocate, sliceId);
- return buildResponse(rsp);
- } catch (ApplicationException e) {
- return e.buildErrorResponse();
- }
- }
-
@PostMapping(value = "/NSS/nssi/{nssiId}")
public ResponseEntity terminateNssi(@RequestBody NssiTerminateRequest terminate,
@PathVariable("nssiId") String nssiId) {
@@ -128,44 +106,6 @@
}
}
- @PostMapping(value = "/NSS/{snssai}/activation")
- public ResponseEntity activateNssi(@RequestBody NssiActDeActRequest activate,
- @PathVariable("snssai") String snssai) {
- try {
- logger.info("Nssmf activate request is invoked");
- assertObjectNotNull(activate);
- RestResponse rsp = getNssmfMgr().activateNssi(activate, snssai);
- return buildResponse(rsp);
- } catch (ApplicationException e) {
- return e.buildErrorResponse();
- }
- }
-
- @PostMapping(value = "/NSS/{snssai}/deactivation")
- public ResponseEntity deactivateNssi(@RequestBody NssiActDeActRequest deActivate,
- @PathVariable("snssai") String snssai) {
- try {
- logger.info("Nssmf activate request is invoked");
- assertObjectNotNull(deActivate);
- RestResponse rsp = getNssmfMgr().deActivateNssi(deActivate, snssai);
- return buildResponse(rsp);
- } catch (ApplicationException e) {
- return e.buildErrorResponse();
- }
- }
-
- @PostMapping(value = "/NSS/jobs/{jobId}")
- public ResponseEntity queryJobStatus(@RequestBody JobStatusRequest jobStatusReq,
- @PathVariable("jobId") String jobId) {
- try {
- logger.info("Nssmf query job status request is invoked");
- assertObjectNotNull(jobStatusReq);
- RestResponse rsp = getNssmfMgr().queryJobStatus(jobStatusReq, jobId);
- return buildResponse(rsp);
- } catch (ApplicationException e) {
- return e.buildErrorResponse();
- }
- }
@GetMapping(value = "/vendor/{vendorName}/type/{networkType}/NSS" + "/SliceProfiles/{sliceProfileId}")
public ResponseEntity queryNssi(@PathVariable("vendorName") String vendorName,
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java
deleted file mode 100644
index 6306643..0000000
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfInfo.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============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.nssmf.rest;
-
-public class NssmfInfo {
-
- private String url;
-
- private String ipAddress;
-
- private String port;
-
- private String insecure;
-
- private String cacert;
-
- private String userName;
-
- private String password;
-
- public String getInsecure() {
- return insecure;
- }
-
- public void setInsecure(String insecure) {
- this.insecure = insecure;
- }
-
- public String getCacert() {
- return cacert;
- }
-
- public void setCacert(String cacert) {
- this.cacert = cacert;
- }
-
- public String getIpAddress() {
- return ipAddress;
- }
-
- public void setIpAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java
index 0e25729..bcce69f 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/NssmfManager.java
@@ -20,7 +20,10 @@
package org.onap.so.adapters.nssmf.rest;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.JobStatus;
import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.util.RestUtil;
import org.onap.so.beans.nsmf.ActDeActNssi;
import org.onap.so.beans.nsmf.AllocateAnNssi;
import org.onap.so.beans.nsmf.AllocateCnNssi;
@@ -52,15 +55,15 @@
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Component;
import static java.lang.String.valueOf;
-import static org.onap.so.adapters.nssmf.rest.HttpMethod.DELETE;
-import static org.onap.so.adapters.nssmf.rest.HttpMethod.GET;
-import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST;
-import static org.onap.so.adapters.nssmf.rest.HttpMethod.PUT;
-import static org.onap.so.adapters.nssmf.rest.JobStatus.ERROR;
-import static org.onap.so.adapters.nssmf.rest.JobStatus.FINISHED;
-import static org.onap.so.adapters.nssmf.rest.JobStatus.PROCESSING;
-import static org.onap.so.adapters.nssmf.rest.JobStatus.STARTED;
-import static org.onap.so.adapters.nssmf.rest.JobStatus.fromString;
+import static org.onap.so.adapters.nssmf.enums.HttpMethod.DELETE;
+import static org.onap.so.adapters.nssmf.enums.HttpMethod.GET;
+import static org.onap.so.adapters.nssmf.enums.HttpMethod.POST;
+import static org.onap.so.adapters.nssmf.enums.HttpMethod.PUT;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.ERROR;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.FINISHED;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.PROCESSING;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.STARTED;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.fromString;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ACTIVATE_NSS_SUCCESS;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.ALLOCATE_NSS_SUCCESS;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.CREATE_NSS_SUCCESS;
@@ -76,6 +79,7 @@
@Component
@Primary
+@Deprecated
public class NssmfManager {
private static final Logger logger = LoggerFactory.getLogger(NssmfManager.class);
@@ -129,14 +133,18 @@
case TRANSPORT:
AllocateTnNssi tn = nssmiAllocate.getAllocateTnNssi();
assertObjectNotNull(tn);
- assertObjectNotNull(tn.getNsiInfo());
- assertObjectNotNull(tn.getNsiInfo().getNsiId());
- nsiId = tn.getNsiInfo().getNsiId();
+ // assertObjectNotNull(tn.getNsiInfo());
+ // assertObjectNotNull(tn.getNsiInfo().getNsiId());
+ // nsiId = tn.getNsiInfo().getNsiId();
allocateReq = marshal(tn);
- allocateUrl = AllocateTnNssi.URL;
+ // allocateUrl = AllocateTnNssi.URL;
break;
}
+
+ /**
+ * 内部的,调用 workflow 外部的,访问第三方api
+ */
RestResponse rsp = restUtil.sendRequest(allocateUrl, POST, allocateReq, nssmiAllocate.getEsrInfo());
assertObjectNotNull(rsp);
@@ -152,6 +160,8 @@
return rsp;
}
+
+
public RestResponse createNssi(NssiCreateRequest nssiCreate) throws ApplicationException {
assertObjectNotNull(nssiCreate.getEsrInfo());
@@ -192,6 +202,7 @@
return rsp;
}
+ @Deprecated
public RestResponse deAllocateNssi(NssiDeAllocateRequest nssiDeallocate, String sliceId)
throws ApplicationException {
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java
index 254186b..fc0f3dd 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/TrustAllHostNameVerifier.java
@@ -23,6 +23,7 @@
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
+@Deprecated
public class TrustAllHostNameVerifier implements HostnameVerifier {
public boolean verify(String hostname, SSLSession session) {
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java
new file mode 100644
index 0000000..9ad191b
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.service;
+
+import org.onap.so.beans.nsmf.*;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface NssmfManagerService {
+ ResponseEntity allocateNssi(NssmfAdapterNBIRequest allocateRequest);
+
+ ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest allocateRequest, String sliceProfileId);
+
+ ResponseEntity activateNssi(NssmfAdapterNBIRequest deActRequest, String snssai);
+
+ ResponseEntity deActivateNssi(NssmfAdapterNBIRequest nssiDeActivate, String snssai);
+
+ ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId);
+
+ ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest);
+
+ ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest);
+
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java
new file mode 100644
index 0000000..1408123
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.service.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.NssmfManagerBuilder;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.manager.NssmfManager;
+import org.onap.so.adapters.nssmf.service.NssmfManagerService;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class NssmfManagerServiceImpl implements NssmfManagerService {
+
+ @Autowired
+ private RestUtil restUtil;
+
+ @Autowired
+ private ResourceOperationStatusRepository repository;
+
+ @Autowired
+ private NssmfAdapterConfig nssmfAdapterConfig;
+
+ @Override
+ public ResponseEntity allocateNssi(NssmfAdapterNBIRequest request) {
+ try {
+
+ if (StringUtils.isNotBlank(request.getServiceInfo().getNssiId())) {
+ return buildResponse(buildNssmfManager(request, ActionType.MODIFY).modifyNssi(request));
+ }
+
+ return buildResponse(buildNssmfManager(request, ActionType.ALLOCATE).allocateNssi(request));
+
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest request, String sliceProfileId) {
+ try {
+ return buildResponse(
+ buildNssmfManager(request, ActionType.DEALLOCATE).deAllocateNssi(request, sliceProfileId));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity activateNssi(NssmfAdapterNBIRequest request, String snssai) {
+ try {
+ return buildResponse(buildNssmfManager(request, ActionType.ACTIVATE).activateNssi(request, snssai));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity deActivateNssi(NssmfAdapterNBIRequest request, String snssai) {
+ try {
+ return buildResponse(buildNssmfManager(request, ActionType.DEACTIVATE).deActivateNssi(request, snssai));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) {
+ try {
+ return buildResponse(buildNssmfManager(jobReq, ActionType.QUERY_JOB_STATUS).queryJobStatus(jobReq, jobId));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) {
+ EsrInfo esrInfo = nbiRequest.getEsrInfo();
+ try {
+ return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_JOB_STATUS, null)
+ .queryNSSISelectionCapability(nbiRequest));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) {
+ EsrInfo esrInfo = nbiRequest.getEsrInfo();
+ try {
+ return buildResponse(
+ buildNssmfManager(esrInfo, ActionType.QUERY_JOB_STATUS, null).querySubnetCapability(nbiRequest));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ private ResponseEntity buildResponse(RestResponse rsp) {
+ return ResponseEntity.status(rsp.getStatus()).body(rsp.getResponseContent());
+ }
+
+
+ private NssmfManager buildNssmfManager(NssmfAdapterNBIRequest request, ActionType actionType)
+ throws ApplicationException {
+ return buildNssmfManager(request.getEsrInfo(), actionType, request.getServiceInfo());
+ }
+
+ private NssmfManager buildNssmfManager(EsrInfo esrInfo, ActionType actionType, ServiceInfo serviceInfo)
+ throws ApplicationException {
+
+ return new NssmfManagerBuilder(esrInfo).setActionType(actionType).setRepository(repository)
+ .setRestUtil(restUtil).setAdapterConfig(nssmfAdapterConfig).setServiceInfo(serviceInfo).build();
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java
index 3a7c2f1..090417d 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java
@@ -22,10 +22,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
+import org.onap.so.adapters.nssmf.enums.ActionType;
import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.logging.filter.base.ErrorCode;
+import org.springframework.stereotype.Component;
import static org.onap.so.logger.LoggingAnchor.THREE;
import static org.onap.so.logger.MessageEnum.RA_NS_EXC;
@@ -45,6 +47,8 @@
public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful";
+ public static final String MODIFY_NSS_SUCCESS = "Modify nss is " + "successful";
+
public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful";
public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful";
@@ -91,4 +95,29 @@
}
}
+
+ public static String getStatusDesc(ActionType actionType) {
+ String desc = "";
+ switch (actionType) {
+ case ALLOCATE:
+ desc = StatusDesc.ALLOCATE_NSS_SUCCESS;
+ break;
+ case DEALLOCATE:
+ desc = StatusDesc.DEALLOCATE_NSS_SUCCESS;
+ break;
+ case ACTIVATE:
+ desc = StatusDesc.ACTIVATE_NSS_SUCCESS;
+ break;
+ case DEACTIVATE:
+ desc = StatusDesc.DEACTIVATE_NSS_SUCCESS;
+ break;
+ case MODIFY:
+ desc = StatusDesc.MODIFY_NSS_SUCCESS;
+ break;
+ default:
+ break;
+ }
+
+ return desc;
+ }
}
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java
similarity index 86%
rename from adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java
rename to adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java
index dcc6f5b..0c5999b 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java
@@ -18,11 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.nssmf.rest;
+package org.onap.so.adapters.nssmf.util;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
+import javax.net.ssl.*;
import javax.ws.rs.core.UriBuilder;
import java.net.SocketTimeoutException;
import java.net.URI;
@@ -30,32 +28,29 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.methods.*;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
-import org.onap.aai.domain.yang.EsrSystemInfo;
-import org.onap.aai.domain.yang.EsrSystemInfoList;
-import org.onap.aai.domain.yang.EsrThirdpartySdnc;
-import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.aai.domain.yang.*;
import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider;
-import org.onap.so.adapters.nssmf.model.TokenRequest;
-import org.onap.so.adapters.nssmf.model.TokenResponse;
+import org.onap.so.adapters.nssmf.entity.TokenRequest;
+import org.onap.so.adapters.nssmf.entity.TokenResponse;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.ServiceInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import static org.apache.http.entity.ContentType.APPLICATION_JSON;
-import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST;
+import static org.onap.so.adapters.nssmf.enums.HttpMethod.POST;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
@@ -77,6 +72,10 @@
@Autowired
private AaiServiceProvider aaiSvcProv;
+ public void createServiceInstance(ServiceInstance serviceInstance, ServiceInfo serviceInfo) {
+ aaiSvcProv.invokeCreateServiceInstance(serviceInstance, serviceInfo.getGlobalSubscriberId(),
+ serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId());
+ }
public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException {
EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList();
@@ -112,10 +111,9 @@
throw new ApplicationException(BAD_REQUEST, "ESR information is improper");
}
- public RestResponse sendRequest(String url, HttpMethod methodType, String content, EsrInfo esrInfo)
- throws ApplicationException {
- NssmfInfo nssmfInfo = getNssmfHost(esrInfo);
+ public String getToken(NssmfInfo nssmfInfo) throws ApplicationException {
+
TokenRequest req = new TokenRequest();
req.setGrantType("password");
@@ -128,13 +126,12 @@
RestResponse tokenRes = send(nssmfInfo.getUrl() + TOKEN_URL, POST, tokenReq, null);
TokenResponse res = unMarshal(tokenRes.getResponseContent(), TokenResponse.class);
- String token = res.getAccessToken();
- Header header = new BasicHeader("X-Auth-Token", token);
- String nssmfUrl = nssmfInfo.getUrl() + url;
- return send(nssmfUrl, methodType, content, header);
+
+ return res.getAccessToken();
}
- private RestResponse send(String url, HttpMethod methodType, String content, Header header) {
+
+ public RestResponse send(String url, HttpMethod methodType, String content, Header header) {
HttpRequestBase req = null;
HttpResponse res = null;
@@ -168,8 +165,6 @@
}
if (null != req) {
req.reset();
- } else {
- logger.debug("method is NULL:");
}
req = null;
@@ -201,7 +196,7 @@
}
}
- private RestResponse createResponse(int statusCode, String errMsg) {
+ public RestResponse createResponse(int statusCode, String errMsg) {
RestResponse restResponse = new RestResponse();
restResponse.setStatus(statusCode);
restResponse.setResponseContent(errMsg);
@@ -210,7 +205,7 @@
private HttpRequestBase getHttpReq(String url, HttpMethod method, Header header, RequestConfig config,
String content) throws ApplicationException {
- HttpRequestBase base = null;
+ HttpRequestBase base;
switch (method) {
case POST:
HttpPost post = new HttpPost(url);
@@ -229,6 +224,7 @@
break;
case PATCH:
+ base = new HttpPatch(url);
break;
case DELETE:
@@ -238,6 +234,8 @@
}
base = delete;
break;
+ default:
+ throw new ApplicationException(404, "invalid method: " + method);
}
base.setConfig(config);
@@ -247,6 +245,14 @@
return base;
}
+ public RestResponse sendRequest(String allocateUrl, HttpMethod post, String allocateReq, EsrInfo esrInfo)
+ throws ApplicationException {
+ NssmfInfo nssmfInfo = getNssmfHost(esrInfo);
+ Header header = new BasicHeader("X-Auth-Token", getToken(nssmfInfo));
+ String nssmfUrl = nssmfInfo.getUrl() + allocateUrl;
+ return send(nssmfUrl, post, allocateReq, header);
+ }
+
class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
@@ -289,7 +295,7 @@
// HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
SSLConnectionSocketFactory sslsf =
- new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, new TrustAllHostNameVerifier());
+ new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, (s, sslSession) -> true);
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (Exception e) {
throw new IllegalArgumentException(e);
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/application-test.yaml b/adapters/mso-nssmf-adapter/src/main/resources/application-test.yaml
new file mode 100644
index 0000000..8e10dfb
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/application-test.yaml
@@ -0,0 +1,60 @@
+
+aai:
+ auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586
+ endpoint: https://aai.onap:30233
+logging:
+ path: logs
+
+spring:
+ datasource:
+ jdbcUrl: jdbc:mariadb://49.232.146.162:8989/requestdb
+ username: root
+ password: 123456
+ driver-class-name: org.mariadb.jdbc.Driver
+ initialization-mode: always
+ jpa:
+ generate-ddl: false
+ show-sql: false
+ hibernate:
+ ddl-auto: none
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ security:
+ usercredentials:
+ - username: bpel
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ - username: mso_admin
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: ACTUATOR
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+ site-name: localSite
+ logPath: ./logs/nssmf
+ adapters:
+ requestDb:
+ endpoint: https://so-request-db-adapter.onap:8083
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+ infra:
+ endpoint: https://so.onap:8080
+ auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
+
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
+ metrics:
+ se-global-registry: false
+ export:
+ prometheus:
+ enabled: true # Whether exporting of metrics to Prometheus is enabled.
+ step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/application.yaml b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml
index 303d63d..8da911d 100644
--- a/adapters/mso-nssmf-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-nssmf-adapter/src/main/resources/application.yaml
@@ -58,6 +58,9 @@
requestDb:
endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083
auth: Basic YnBlbDpwYXNzd29yZDEk
+ infra:
+ endpoint: https://so.{{ include "common.namespace" . }}:8080
+ auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
#Actuator
management:
diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java
index 5bfd390..a9c732e 100644
--- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java
+++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java
@@ -24,6 +24,7 @@
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
+import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
@@ -35,12 +36,12 @@
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.onap.so.adapters.nssmf.model.TokenResponse;
-import org.onap.so.adapters.nssmf.rest.HttpMethod;
+import org.onap.so.adapters.nssmf.entity.TokenResponse;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
import org.onap.so.adapters.nssmf.rest.NssmfAdapterRest;
-import org.onap.so.adapters.nssmf.rest.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
import org.onap.so.adapters.nssmf.rest.NssmfManager;
-import org.onap.so.adapters.nssmf.rest.RestUtil;
+import org.onap.so.adapters.nssmf.util.RestUtil;
import org.onap.so.beans.nsmf.ActDeActNssi;
import org.onap.so.beans.nsmf.AllocateCnNssi;
import org.onap.so.beans.nsmf.CnSliceProfile;
@@ -127,13 +128,16 @@
}
private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception {
+ when(this.restUtil.send(any(String.class), any(HttpMethod.class), any(String.class), any(Header.class)))
+ .thenCallRealMethod();
+ when(this.restUtil.createResponse(any(Integer.class), any(String.class))).thenCallRealMethod();
when(nssmfRest.getNssmfMgr()).thenReturn(nssmfMgr);
- when(nssmfRest.allocateNssi(any(NssiAllocateRequest.class))).thenCallRealMethod();
- when(nssmfRest.deAllocateNssi(any(NssiDeAllocateRequest.class), any(String.class))).thenCallRealMethod();
- when(nssmfRest.activateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod();
- when(nssmfRest.deactivateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod();
-
- when(nssmfRest.queryJobStatus(any(JobStatusRequest.class), any(String.class))).thenCallRealMethod();
+ // when(nssmfRest.createAllocateNssi(any(NssiAllocateRequest.class))).thenCallRealMethod();
+ // when(nssmfRest.deAllocateNssi(any(NssiDeAllocateRequest.class), any(String.class))).thenCallRealMethod();
+ // when(nssmfRest.activateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod();
+ // when(nssmfRest.deactivateNssi(any(NssiActDeActRequest.class), any(String.class))).thenCallRealMethod();
+ //
+ // when(nssmfRest.queryJobStatus(any(JobStatusRequest.class), any(String.class))).thenCallRealMethod();
when(restUtil.sendRequest(any(String.class), any(HttpMethod.class), any(String.class), any(EsrInfo.class)))
.thenCallRealMethod();
when(restUtil.getHttpsClient()).thenReturn(httpClient);
@@ -168,113 +172,113 @@
doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class));
}
- @Test
- public void testNssiAllocate() throws Exception {
- NssmfInfo nssmf = new NssmfInfo();
- nssmf.setUserName("nssmf-user");
- nssmf.setPassword("nssmf-pass");
- nssmf.setPort("8080");
- nssmf.setIpAddress("127.0.0.1");
-
- NssiResponse nssiRes = new NssiResponse();
- nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
- nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
-
- TokenResponse token = new TokenResponse();
- token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
- token.setExpires(1800);
-
- postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
- tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
-
- createCommonMock(200, nssmf);
- // assertEquals(prettyPrint(allocateNssi()), ALLOCATE);
- ResponseEntity res = nssmfRest.allocateNssi(allocateNssi());
- assertNotNull(res);
- assertNotNull(res.getBody());
- NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
- assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
- assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
- }
-
- @Test
- public void testNssiDeAllocate() throws Exception {
- NssmfInfo nssmf = new NssmfInfo();
- nssmf.setUserName("nssmf-user");
- nssmf.setPassword("nssmf-pass");
- nssmf.setPort("8080");
- nssmf.setIpAddress("127.0.0.1");
-
- NssiResponse nssiRes = new NssiResponse();
- nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
-
- TokenResponse token = new TokenResponse();
- token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
- token.setExpires(1800);
-
- postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
- tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
-
- createCommonMock(200, nssmf);
- ResponseEntity res = nssmfRest.deAllocateNssi(deAllocateNssi(), "ab9af40f13f721b5f13539d87484098");
- assertNotNull(res);
- assertNotNull(res.getBody());
- NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
- assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
- }
-
- @Test
- public void testNssiActivate() throws Exception {
- NssmfInfo nssmf = new NssmfInfo();
- nssmf.setUserName("nssmf-user");
- nssmf.setPassword("nssmf-pass");
- nssmf.setPort("8080");
- nssmf.setIpAddress("127.0.0.1");
-
- NssiResponse nssiRes = new NssiResponse();
- nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
-
- TokenResponse token = new TokenResponse();
- token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
- token.setExpires(1800);
-
- postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
- tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
-
- createCommonMock(200, nssmf);
- ResponseEntity res = nssmfRest.activateNssi(activateNssi(), "001-100001");
- assertNotNull(res);
- assertNotNull(res.getBody());
- NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
- assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
- }
-
- @Test
- public void testNssiDeActivate() throws Exception {
- NssmfInfo nssmf = new NssmfInfo();
- nssmf.setUserName("nssmf-user");
- nssmf.setPassword("nssmf-pass");
- nssmf.setPort("8080");
- nssmf.setIpAddress("127.0.0.1");
-
- NssiResponse nssiRes = new NssiResponse();
- nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
-
- TokenResponse token = new TokenResponse();
- token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
- token.setExpires(1800);
-
- postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
- tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
-
- createCommonMock(200, nssmf);
- ResponseEntity res = nssmfRest.deactivateNssi(deActivateNssi(), "001-100001");
- assertNotNull(res);
- assertNotNull(res.getBody());
- NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
- assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
- }
-
+ // @Test
+ // public void testNssiAllocate() throws Exception {
+ // NssmfInfo nssmf = new NssmfInfo();
+ // nssmf.setUserName("nssmf-user");
+ // nssmf.setPassword("nssmf-pass");
+ // nssmf.setPort("8080");
+ // nssmf.setIpAddress("127.0.0.1");
+ //
+ // NssiResponse nssiRes = new NssiResponse();
+ // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ // nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ //
+ // TokenResponse token = new TokenResponse();
+ // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ // token.setExpires(1800);
+ //
+ // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+ //
+ // createCommonMock(200, nssmf);
+ // // assertEquals(prettyPrint(createAllocateNssi()), ALLOCATE);
+ // ResponseEntity res = nssmfRest.createAllocateNssi(createAllocateNssi());
+ // assertNotNull(res);
+ // assertNotNull(res.getBody());
+ // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ // assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ // }
+ //
+ // @Test
+ // public void testNssiDeAllocate() throws Exception {
+ // NssmfInfo nssmf = new NssmfInfo();
+ // nssmf.setUserName("nssmf-user");
+ // nssmf.setPassword("nssmf-pass");
+ // nssmf.setPort("8080");
+ // nssmf.setIpAddress("127.0.0.1");
+ //
+ // NssiResponse nssiRes = new NssiResponse();
+ // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ //
+ // TokenResponse token = new TokenResponse();
+ // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ // token.setExpires(1800);
+ //
+ // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+ //
+ // createCommonMock(200, nssmf);
+ // ResponseEntity res = nssmfRest.deAllocateNssi(deAllocateNssi(), "ab9af40f13f721b5f13539d87484098");
+ // assertNotNull(res);
+ // assertNotNull(res.getBody());
+ // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ // }
+ //
+ // @Test
+ // public void testNssiActivate() throws Exception {
+ // NssmfInfo nssmf = new NssmfInfo();
+ // nssmf.setUserName("nssmf-user");
+ // nssmf.setPassword("nssmf-pass");
+ // nssmf.setPort("8080");
+ // nssmf.setIpAddress("127.0.0.1");
+ //
+ // NssiResponse nssiRes = new NssiResponse();
+ // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ //
+ // TokenResponse token = new TokenResponse();
+ // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ // token.setExpires(1800);
+ //
+ // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+ //
+ // createCommonMock(200, nssmf);
+ // ResponseEntity res = nssmfRest.activateNssi(activateNssi(), "001-100001");
+ // assertNotNull(res);
+ // assertNotNull(res.getBody());
+ // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ // }
+ //
+ // @Test
+ // public void testNssiDeActivate() throws Exception {
+ // NssmfInfo nssmf = new NssmfInfo();
+ // nssmf.setUserName("nssmf-user");
+ // nssmf.setPassword("nssmf-pass");
+ // nssmf.setPort("8080");
+ // nssmf.setIpAddress("127.0.0.1");
+ //
+ // NssiResponse nssiRes = new NssiResponse();
+ // nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ //
+ // TokenResponse token = new TokenResponse();
+ // token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ // token.setExpires(1800);
+ //
+ // postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ // tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+ //
+ // createCommonMock(200, nssmf);
+ // ResponseEntity res = nssmfRest.deactivateNssi(deActivateNssi(), "001-100001");
+ // assertNotNull(res);
+ // assertNotNull(res.getBody());
+ // NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ // assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ // }
+ //
@Test
public void testAllocateJsonSerDeSer() throws Exception {
assertEquals(marshal(allocateNssi()), ALLOCATE);
@@ -334,50 +338,51 @@
return allocate;
}
- public NssiDeAllocateRequest deAllocateNssi() throws Exception {
- DeAllocateNssi deAllocateNssi = new DeAllocateNssi();
- deAllocateNssi.setTerminateNssiOption(0);
- List<String> snssai = new LinkedList<>();
- snssai.add("001-100001");
- deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
- deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
- deAllocateNssi.setScriptName("CN1");
- deAllocateNssi.setSnssaiList(snssai);
- EsrInfo esrInfo = new EsrInfo();
- esrInfo.setVendor("huawei");
- esrInfo.setNetworkType(CORE);
- NssiDeAllocateRequest deAllocate = new NssiDeAllocateRequest();
- deAllocate.setDeAllocateNssi(deAllocateNssi);
- deAllocate.setEsrInfo(esrInfo);
- return deAllocate;
- }
-
- public NssiActDeActRequest activateNssi() throws Exception {
- EsrInfo esrInfo = new EsrInfo();
- esrInfo.setVendor("huawei");
- esrInfo.setNetworkType(CORE);
- ActDeActNssi act = new ActDeActNssi();
- act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
- act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
- NssiActDeActRequest actReq = new NssiActDeActRequest();
- actReq.setActDeActNssi(act);
- actReq.setEsrInfo(esrInfo);
- return actReq;
- }
-
- public NssiActDeActRequest deActivateNssi() throws Exception {
- EsrInfo esrInfo = new EsrInfo();
- esrInfo.setVendor("huawei");
- esrInfo.setNetworkType(CORE);
- ActDeActNssi deAct = new ActDeActNssi();
- deAct.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
- deAct.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
- NssiActDeActRequest deActReq = new NssiActDeActRequest();
- deActReq.setActDeActNssi(deAct);
- deActReq.setEsrInfo(esrInfo);
- return deActReq;
- }
-
+ //
+ // public NssiDeAllocateRequest deAllocateNssi() throws Exception {
+ // DeAllocateNssi deAllocateNssi = new DeAllocateNssi();
+ // deAllocateNssi.setTerminateNssiOption(0);
+ // List<String> snssai = new LinkedList<>();
+ // snssai.add("001-100001");
+ // deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ // deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ // deAllocateNssi.setScriptName("CN1");
+ // deAllocateNssi.setSnssaiList(snssai);
+ // EsrInfo esrInfo = new EsrInfo();
+ // esrInfo.setVendor("huawei");
+ // esrInfo.setNetworkType(CORE);
+ // NssiDeAllocateRequest deAllocate = new NssiDeAllocateRequest();
+ // deAllocate.setDeAllocateNssi(deAllocateNssi);
+ // deAllocate.setEsrInfo(esrInfo);
+ // return deAllocate;
+ // }
+ //
+ // public NssiActDeActRequest activateNssi() throws Exception {
+ // EsrInfo esrInfo = new EsrInfo();
+ // esrInfo.setVendor("huawei");
+ // esrInfo.setNetworkType(CORE);
+ // ActDeActNssi act = new ActDeActNssi();
+ // act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ // act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ // NssiActDeActRequest actReq = new NssiActDeActRequest();
+ // actReq.setActDeActNssi(act);
+ // actReq.setEsrInfo(esrInfo);
+ // return actReq;
+ // }
+ //
+ // public NssiActDeActRequest deActivateNssi() throws Exception {
+ // EsrInfo esrInfo = new EsrInfo();
+ // esrInfo.setVendor("huawei");
+ // esrInfo.setNetworkType(CORE);
+ // ActDeActNssi deAct = new ActDeActNssi();
+ // deAct.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ // deAct.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ // NssiActDeActRequest deActReq = new NssiActDeActRequest();
+ // deActReq.setActDeActNssi(deAct);
+ // deActReq.setEsrInfo(esrInfo);
+ // return deActReq;
+ // }
+ //
public String queryJobStatusNssi() throws Exception {
EsrInfo esrInfo = new EsrInfo();
esrInfo.setVendor("huawei");
diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java
new file mode 100644
index 0000000..3108ade
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java
@@ -0,0 +1,438 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # 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.nssmf.service.impl;
+
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.stubbing.Answer;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.TokenResponse;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.*;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+import static org.onap.so.beans.nsmf.NetworkType.CORE;
+import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED;
+
+@RunWith(SpringRunner.class)
+public class NssmfManagerServiceImplTest {
+
+ @Mock
+ private RestUtil restUtil;
+
+
+ private NssmfManagerServiceImpl nssiManagerService;
+
+ @Mock
+ private HttpResponse tokenResponse;
+
+ @Mock
+ private HttpEntity tokenEntity;
+
+ @Mock
+ private HttpResponse commonResponse;
+
+ @Mock
+ private HttpEntity commonEntity;
+
+ @Mock
+ private StatusLine statusLine;
+
+ @Mock
+ private HttpClient httpClient;
+
+ private InputStream postStream;
+
+ private InputStream tokenStream;
+
+ @Mock
+ private ResourceOperationStatusRepository repository;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+
+ nssiManagerService = new NssmfManagerServiceImpl();
+
+ Field restUtil = nssiManagerService.getClass().getDeclaredField("restUtil");
+ restUtil.setAccessible(true);
+ restUtil.set(nssiManagerService, this.restUtil);
+
+ Field repository = nssiManagerService.getClass().getDeclaredField("repository");
+ repository.setAccessible(true);
+ repository.set(nssiManagerService, this.repository);
+ // nssiManagerService.setRestUtil(this.restUtil);
+
+ when(this.restUtil.send(any(String.class), any(HttpMethod.class), any(), any(Header.class)))
+ .thenCallRealMethod();
+ when(this.restUtil.createResponse(any(Integer.class), any(String.class))).thenCallRealMethod();
+ }
+
+ private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception {
+ when(restUtil.getToken(any(NssmfInfo.class))).thenReturn("7512eb3feb5249eca5ddd742fedddd39");
+ when(restUtil.getHttpsClient()).thenReturn(httpClient);
+
+ when(statusLine.getStatusCode()).thenReturn(statusCode);
+ when(restUtil.getNssmfHost(any(EsrInfo.class))).thenReturn(nssmf);
+
+ when(tokenResponse.getEntity()).thenReturn(tokenEntity);
+ when(tokenResponse.getStatusLine()).thenReturn(statusLine);
+ when(tokenEntity.getContent()).thenReturn(tokenStream);
+
+ when(commonResponse.getEntity()).thenReturn(commonEntity);
+ when(commonResponse.getStatusLine()).thenReturn(statusLine);
+ when(commonEntity.getContent()).thenReturn(postStream);
+
+ Answer<HttpResponse> answer = invocation -> {
+ Object[] arguments = invocation.getArguments();
+ if (arguments != null && arguments.length == 1 && arguments[0] != null) {
+
+ HttpRequestBase base = (HttpRequestBase) arguments[0];
+ if (base.getURI().toString().endsWith("/oauth/token")) {
+ return tokenResponse;
+ } else {
+ return commonResponse;
+ }
+ }
+ return commonResponse;
+ };
+
+ doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class));
+
+ }
+
+ @Test
+ public void allocateNssi() throws Exception {
+
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+ nssmf.setUrl("http://127.0.0.1:8080");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(200, nssmf);
+
+
+ NssmfAdapterNBIRequest nbiRequest = createAllocateNssi();
+ assertNotNull(nbiRequest);
+ System.out.println(marshal(nbiRequest));
+ ResponseEntity res = nssiManagerService.allocateNssi(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ System.out.println(res);
+ }
+
+
+
+ private NssmfAdapterNBIRequest createAllocateNssi() {
+ CnSliceProfile sP = new CnSliceProfile();
+ List<String> sns = new LinkedList<>();
+ sns.add("001-100001");
+ List<String> plmn = new LinkedList<>();
+ plmn.add("460-00");
+ plmn.add("460-01");
+ PerfReqEmbbList embb = new PerfReqEmbbList();
+ embb.setActivityFactor(50);
+ List<PerfReqEmbbList> embbList = new LinkedList<>();
+ embbList.add(embb);
+ PerfReq perfReq = new PerfReq();
+ perfReq.setPerfReqEmbbList(embbList);
+ List<String> taList = new LinkedList<>();
+ taList.add("1");
+ taList.add("2");
+ taList.add("3");
+ sP.setSnssaiList(sns);
+ sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098");
+ sP.setPlmnIdList(plmn);
+ sP.setPerfReq(perfReq);
+ sP.setMaxNumberofUEs(200);
+ sP.setCoverageAreaTAList(taList);
+ sP.setLatency(6);
+ sP.setResourceSharingLevel(NON_SHARED);
+ NsiInfo nsiInfo = new NsiInfo();
+ nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nsiInfo.setNsiName("eMBB-001");
+ AllocateCnNssi cnNssi = new AllocateCnNssi();
+ cnNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX");
+ cnNssi.setNssiName("eMBB-001");
+ cnNssi.setScriptName("CN1");
+ cnNssi.setSliceProfile(sP);
+ cnNssi.setNsiInfo(nsiInfo);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+ nbiRequest.setAllocateCnNssi(cnNssi);
+ return nbiRequest;
+ }
+
+ @Test
+ public void deAllocateNssi() throws Exception {
+ DeAllocateNssi deAllocateNssi = new DeAllocateNssi();
+ deAllocateNssi.setTerminateNssiOption(0);
+ List<String> snssai = new LinkedList<>();
+ snssai.add("001-100001");
+ deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ deAllocateNssi.setScriptName("CN1");
+ deAllocateNssi.setSnssaiList(snssai);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+ nbiRequest.setDeAllocateNssi(deAllocateNssi);
+
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(202, nssmf);
+ ResponseEntity res = nssiManagerService.deAllocateNssi(nbiRequest, "ab9af40f13f721b5f13539d87484098");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ }
+
+ @Test
+ public void activateNssi() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ ActDeActNssi act = new ActDeActNssi();
+ act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+ nbiRequest.setActDeActNssi(act);
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssiManagerService.activateNssi(nbiRequest, "001-100001");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+
+ @Test
+ public void deActivateNssi() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ ActDeActNssi act = new ActDeActNssi();
+ act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+ nbiRequest.setActDeActNssi(act);
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssiManagerService.deActivateNssi(nbiRequest, "001-100001");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+
+ @Test
+ public void queryJobStatus() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ JobStatusResponse jobStatusResponse = new JobStatusResponse();
+ ResponseDescriptor descriptor = new ResponseDescriptor();
+ descriptor.setResponseId("7512eb3feb5249eca5ddd742fedddd39");
+ descriptor.setProgress(20);
+ descriptor.setStatusDescription("Initiating VNF Instance");
+ descriptor.setStatus("processing");
+ jobStatusResponse.setResponseDescriptor(descriptor);
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(jobStatusResponse).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ ResourceOperationStatus operationStatus = new ResourceOperationStatus();
+ operationStatus.setOperationId("4b45d919816ccaa2b762df5120f72067");
+ operationStatus.setResourceTemplateUUID("8ee5926d-720b-4bb2-86f9-d20e921c143b");
+ operationStatus.setServiceId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+ nbiRequest.setResponseId("7512eb3feb5249eca5ddd742fedddd39");
+ Optional<ResourceOperationStatus> optional = Optional.of(operationStatus);
+
+ doAnswer(invocation -> optional).when(repository).findOne(any());
+
+ createCommonMock(200, nssmf);
+
+ ResponseEntity res = nssiManagerService.queryJobStatus(nbiRequest, "4b45d919816ccaa2b762df5120f72067");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ JobStatusResponse allRes = unMarshal(res.getBody().toString(), JobStatusResponse.class);
+ assertEquals(allRes.getResponseDescriptor().getProgress(), 20);
+ assertEquals(allRes.getResponseDescriptor().getStatus(), "processing");
+ assertEquals(allRes.getResponseDescriptor().getResponseId(), "7512eb3feb5249eca5ddd742fedddd39");
+
+ System.out.println(res);
+
+ }
+
+ @Test
+ public void queryNSSISelectionCapability() throws Exception {
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+ ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ Map allRes = unMarshal(res.getBody().toString(), Map.class);
+ assertEquals(allRes.get("selection"), "NSMF");
+
+ System.out.println(res);
+
+ nbiRequest.getEsrInfo().setVendor(NssmfAdapterConsts.ONAP_INTERNAL_TAG);
+ res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ allRes = unMarshal(res.getBody().toString(), Map.class);
+ assertEquals(allRes.get("selection"), "NSSMF");
+
+ System.out.println(res);
+
+ nbiRequest.getEsrInfo().setNetworkType(NetworkType.ACCESS);
+ res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ allRes = unMarshal(res.getBody().toString(), Map.class);
+ assertEquals(allRes.get("selection"), "NSSMF");
+
+ System.out.println(res);
+ }
+
+ private NssmfAdapterNBIRequest createNbiRequest() {
+ NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest();
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b");
+ serviceInfo.setServiceInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51");
+ serviceInfo.setGlobalSubscriberId("5GCustomer");
+ serviceInfo.setServiceType("5G");
+ serviceInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nbiRequest.setEsrInfo(esrInfo);
+ nbiRequest.setServiceInfo(serviceInfo);
+ return nbiRequest;
+ }
+
+ @Test
+ public void querySubnetCapability() {
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
+
+ String subnetCapabilityQuery = "\"subnetTypes\": [\"TN-FH\",\"TN-MH\",\"TN-BH\"]";
+ nbiRequest.setSubnetCapabilityQuery(subnetCapabilityQuery);
+ ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/test/resources/application-test.yaml b/adapters/mso-nssmf-adapter/src/test/resources/application-test.yaml
new file mode 100644
index 0000000..fa323e8
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/test/resources/application-test.yaml
@@ -0,0 +1,60 @@
+
+aai:
+ auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586
+ endpoint: https://aai.onap:30233
+logging:
+ path: logs
+
+spring:
+ datasource:
+ username: root
+ password: 123456
+ driver-class-name: org.mariadb.jdbc.Driver
+ initialization-mode: always
+ url: jdbc:mariadb://49.232.146.162:8989/requestdb
+ jpa:
+ generate-ddl: false
+ show-sql: false
+ hibernate:
+ ddl-auto: none
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ security:
+ usercredentials:
+ - username: bpel
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ - username: mso_admin
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: ACTUATOR
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+ site-name: localSite
+ logPath: ./logs/nssmf
+ adapters:
+ requestDb:
+ endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+ infra:
+ endpoint: https://so.{{ include "common.namespace" . }}:8080
+ auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
+
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
+ metrics:
+ se-global-registry: false
+ export:
+ prometheus:
+ enabled: true # Whether exporting of metrics to Prometheus is enabled.
+ step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml
index ad41b0f..eb6cba5 100644
--- a/adapters/mso-openstack-adapters/pom.xml
+++ b/adapters/mso-openstack-adapters/pom.xml
@@ -298,7 +298,7 @@
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
- <version>1.4.0</version>
+ <version>1.4.1</version>
</dependency>
<!-- added for unit testing -->
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
index ef2577d..10f39f7 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
@@ -49,6 +49,7 @@
import org.onap.aai.domain.yang.Flavor;
import org.onap.aai.domain.yang.Image;
import org.onap.aai.domain.yang.L3InterfaceIpv4AddressList;
+import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.LInterface;
import org.onap.aai.domain.yang.PInterface;
@@ -303,6 +304,8 @@
Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT);
List<String> portIds =
extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE);
+ if (portIds == null)
+ return;
for (String portId : portIds) {
Port port = osClient.getPortById(portId);
Network network = osClient.getNetworkById(port.getNetworkId());
@@ -320,7 +323,7 @@
lIf.setInterfaceRole(port.getvNicType());
}
boolean isL2Multicast = false;
- if (port.getProfile().get("trusted") != null) {
+ if (port.getProfile() != null && port.getProfile().get("trusted") != null) {
String trusted = port.getProfile().get("trusted").toString();
if (Boolean.parseBoolean(trusted)) {
isL2Multicast = true;
@@ -522,6 +525,20 @@
.cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId())
.lInterface(lIf.getInterfaceName()).l3InterfaceIpv4AddressList(ipAddress)),
Optional.of(lInterfaceIp));
+ } else if (InetAddressValidator.getInstance().isValidInet6Address(ipAddress)) {
+ Subnet subnet = osClient.getSubnetById(ip.getSubnetId());
+ IPAddressString cidr = new IPAddressString(subnet.getCidr());
+ L3InterfaceIpv6AddressList ipv6 = new L3InterfaceIpv6AddressList();
+ ipv6.setL3InterfaceIpv6Address(ipAddress);
+ ipv6.setNeutronNetworkId(port.getNetworkId());
+ ipv6.setNeutronSubnetId(ip.getSubnetId());
+ ipv6.setL3InterfaceIpv6PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString()));
+
+ transaction.createIfNotExists(
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId())
+ .lInterface(lIf.getInterfaceName()).l3InterfaceIpv6AddressList(ipAddress)),
+ Optional.of(ipv6));
}
}
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index 8c21e3f..03f6c73 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -423,6 +423,18 @@
when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId,
HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id"));
+ IP ip = mock(IP.class);
+
+ Set<IP> ipSet = new HashSet<>();
+ ipSet.add(ip);
+ when(ip.getIpAddress()).thenReturn("2606:ae00:2e60:100::226");
+ when(ip.getSubnetId()).thenReturn("testSubnetId");
+ when(port.getFixedIps()).thenAnswer(x -> ipSet);
+
+ Subnet subnet = mock(Subnet.class);
+ when(subnet.getCidr()).thenReturn("169.254.100.0/24");
+ when(osClient.getSubnetById("testSubnetId")).thenReturn(subnet);
+
Network network = mock(Network.class);
when(network.getId()).thenReturn("test-network-id");
when(network.getNetworkType()).thenReturn(NetworkType.VLAN);
@@ -446,8 +458,9 @@
heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner");
// Assert
- verify(transaction, times(15)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(transaction, times(20)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
verify(osClient, times(5)).getPortById(anyString());
+ verify(osClient, times(5)).getSubnetById("testSubnetId");
verify(osClient, times(10)).getNetworkById(anyString());
}
diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml
index 2229c1a..68814fc 100644
--- a/adapters/so-appc-orchestrator/pom.xml
+++ b/adapters/so-appc-orchestrator/pom.xml
@@ -56,6 +56,16 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>original</id>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java
index 65e7b35..99b83f1 100644
--- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java
+++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java
@@ -59,9 +59,9 @@
private static final String CLIENT_NAME = "MSO";
- private static final String API_VER = "2.00";
- private static final String ORIGINATOR_ID = "MSO";
- private static final int FLAGS_TTL = 65000;
+ protected static final String API_VER = "2.00";
+ protected static final String ORIGINATOR_ID = "MSO";
+ protected static final int FLAGS_TTL = 65000;
private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClient.class);
@Autowired
@@ -216,13 +216,12 @@
return requestObject;
}
- private CommonHeader buildCommonHeader(String requestId, String requestorId) {
+ protected CommonHeader buildCommonHeader(String requestId, String requestorId) {
CommonHeader commonHeader = new CommonHeader();
commonHeader.setApiVer(API_VER);
commonHeader.setOriginatorId(ORIGINATOR_ID);
commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId);
commonHeader.setSubRequestId(UUID.randomUUID().toString());
- // commonHeader.setXOnapRequestorid(requestorId);
Flags flags = new Flags();
String flagsMode = "NORMAL";
Mode mode = Mode.valueOf(flagsMode);
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
index 08c032f..1468893 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
@@ -64,208 +64,211 @@
class SniroHomingV1 extends AbstractServiceTaskProcessor{
private static final Logger logger = LoggerFactory.getLogger( SniroHomingV1.class);
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- SniroUtils sniroUtils = new SniroUtils(this)
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ SniroUtils sniroUtils = new SniroUtils(this)
- /**
- * This method validates the incoming variables.
- * The method then prepares the sniro request
- * and posts it to sniro's rest api.
- *
- * @param execution
- *
- * @author cb645j
- */
- public void callSniro(DelegateExecution execution){
- execution.setVariable("prefix","HOME_")
- logger.trace("Started Sniro Homing Call Sniro ")
- try{
- execution.setVariable("rollbackData", null)
- execution.setVariable("rolledBack", false)
+ /**
+ * This method validates the incoming variables.
+ * The method then prepares the sniro request
+ * and posts it to sniro's rest api.
+ *
+ * @param execution
+ *
+ * @author cb645j
+ */
+ public void callSniro(DelegateExecution execution){
+ execution.setVariable("prefix","HOME_")
+ logger.trace("Started Sniro Homing Call Sniro ")
+ try{
+ execution.setVariable("rollbackData", null)
+ execution.setVariable("rolledBack", false)
- String requestId = execution.getVariable("msoRequestId")
- logger.debug("Incoming Request Id is: " + requestId)
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- logger.debug("Incoming Service Decomposition is: " + serviceDecomposition)
- String subscriberInfo = execution.getVariable("subscriberInfo")
- logger.debug("Incoming Subscriber Information is: " + subscriberInfo)
+ String requestId = execution.getVariable("msoRequestId")
+ logger.debug("Incoming Request Id is: " + requestId)
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ logger.debug("Incoming Service Decomposition is: " + serviceDecomposition)
+ String subscriberInfo = execution.getVariable("subscriberInfo")
+ logger.debug("Incoming Subscriber Information is: " + subscriberInfo)
- if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){
- exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null")
- }else{
- String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")
- String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")
- String subCommonSiteId = ""
- if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){
- subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")
- }
- Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId)
+ if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null")
+ }else{
+ String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")
+ String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")
+ String subCommonSiteId = ""
+ if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){
+ subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")
+ }
+ Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId)
- String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used
- String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format
+ String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used
+ String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format
- //Authentication
- String authHeader = UrnPropertiesReader.getVariable("sniro.manager.headers.auth", execution)
- execution.setVariable("BasicAuthHeaderValue", authHeader)
+ //Authentication
+ String authHeader = UrnPropertiesReader.getVariable("sniro.manager.headers.auth", execution)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
- //Prepare Callback
- String timeout = execution.getVariable("timeout")
- if(isBlank(timeout)){
- timeout = UrnPropertiesReader.getVariable("sniro.manager.timeout", execution)
- if(isBlank(timeout)) {
- timeout = "PT30M";
- }
- }
- logger.debug("Async Callback Timeout will be: " + timeout)
+ //Prepare Callback
+ String timeout = execution.getVariable("timeout")
+ if(isBlank(timeout)){
+ timeout = UrnPropertiesReader.getVariable("sniro.manager.timeout", execution)
+ if(isBlank(timeout)) {
+ timeout = "PT30M";
+ }
+ }
+ logger.debug("Async Callback Timeout will be: " + timeout)
- execution.setVariable("timeout", timeout);
- execution.setVariable("correlator", requestId);
- execution.setVariable("messageType", "SNIROResponse");
+ execution.setVariable("timeout", timeout);
+ execution.setVariable("correlator", requestId);
+ execution.setVariable("messageType", "SNIROResponse");
- //Build Request & Call Sniro
- String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters)
- execution.setVariable("sniroRequest", sniroRequest)
- logger.debug("SNIRO Request is: " + sniroRequest)
+ //Build Request & Call Sniro
+ String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters)
+ execution.setVariable("sniroRequest", sniroRequest)
+ logger.debug("SNIRO Request is: " + sniroRequest)
- String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution)
- String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution)
- String urlString = host + endpoint
- logger.debug("Sniro Url is: " + urlString)
+ String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution)
+ String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution)
+ String urlString = host + endpoint
+ logger.debug("Sniro Url is: " + urlString)
- URL url = new URL(urlString);
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SNIRO)
- httpClient.addAdditionalHeader("Authorization", authHeader)
- Response httpResponse = httpClient.post(sniroRequest)
+ URL url = new URL(urlString);
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SNIRO)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(sniroRequest)
- int responseCode = httpResponse.getStatus()
+ int responseCode = httpResponse.getStatus()
- logger.debug("Sniro sync response code is: " + responseCode)
- if(httpResponse.hasEntity()){
- logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
- }
+ logger.debug("Sniro sync response code is: " + responseCode)
+ if(httpResponse.hasEntity()){
+ logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
+ }
- if(responseCode != 202){
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")
- }
+ if(responseCode != 202){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")
+ }
- logger.trace("Completed Sniro Homing Call Sniro")
- }
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- logger.debug("Error encountered within Homing CallSniro method: " + e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage())
- }
- }
+ logger.trace("Completed Sniro Homing Call Sniro")
+ }
+ }catch(BpmnError b){
+ throw b
+ }catch(Exception e){
+ logger.debug("Error encountered within Homing CallSniro method: " + e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage())
+ }
+ }
- /**
- * This method processes the callback response
- * and the contained homing solution. It sets
- * homing solution assignment and license
- * information to the corresponding resources
- *
- * @param execution
- *
- * @author cb645j
- */
- public void processHomingSolution(DelegateExecution execution){
- logger.trace("Started Sniro Homing Process Homing Solution")
- try{
- String response = execution.getVariable("asyncCallbackResponse")
- logger.debug("Sniro Async Callback Response is: " + response)
+ /**
+ * This method processes the callback response
+ * and the contained homing solution. It sets
+ * homing solution assignment and license
+ * information to the corresponding resources
+ *
+ * @param execution
+ *
+ * @author cb645j
+ */
+ public void processHomingSolution(DelegateExecution execution){
+ logger.trace("Started Sniro Homing Process Homing Solution")
+ try{
+ String response = execution.getVariable("asyncCallbackResponse")
+ logger.debug("Sniro Async Callback Response is: " + response)
- sniroUtils.validateCallbackResponse(execution, response)
+ sniroUtils.validateCallbackResponse(execution, response)
- ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition")
- List<Resource> resourceList = decomposition.getServiceResources()
+ ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition")
+ List<Resource> resourceList = decomposition.getServiceResources()
- if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){
- String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo")
- JSONArray arr = new JSONArray(placements)
- for(int i = 0; i < arr.length(); i++){
- JSONObject placement = arr.getJSONObject(i)
- String jsonServiceResourceId = placement.getString("serviceResourceId")
- for(Resource resource:resourceList){
- String serviceResourceId = resource.getResourceId()
- if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
- //match
- String inventoryType = placement.getString("inventoryType")
- resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
- resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId"))
- resource.getHomingSolution().setRehome(placement.getBoolean("isRehome"))
- JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
- Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue")
- resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner"))
- resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli"))
- resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion"))
- if(inventoryType.equalsIgnoreCase("service")){
- VnfResource vnf = new VnfResource()
- vnf.setVnfHostname(assignmentMap.get("vnfHostName"))
- resource.getHomingSolution().setVnf(vnf)
- resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId"))
- }
- }
- }
- }
- }
+ if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){
+ String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo")
+ JSONArray arr = new JSONArray(placements)
+ for(int i = 0; i < arr.length(); i++){
+ JSONObject placement = arr.getJSONObject(i)
+ String jsonServiceResourceId = placement.getString("serviceResourceId")
+ for(Resource resource:resourceList){
+ String serviceResourceId = resource.getResourceId()
+ if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
+ //match
+ String inventoryType = placement.getString("inventoryType")
+ resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
+ resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId"))
+ resource.getHomingSolution().setRehome(placement.getBoolean("isRehome"))
+ JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
+ Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue")
+ resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner"))
+ resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli"))
+ resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion"))
+ if(inventoryType.equalsIgnoreCase("service")){
+ VnfResource vnf = new VnfResource()
+ vnf.setVnfHostname(assignmentMap.get("vnfHostName"))
+ resource.getHomingSolution().setVnf(vnf)
+ resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId"))
+ }
+ if(placement.getBoolean("isRehome")) {
+ resource.getHomingSolution().setAllottedResourceId(assignmentMap.get("serviceResourceId"))
+ }
+ }
+ }
+ }
+ }
- if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){
- String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo")
- JSONArray licenseArr = new JSONArray(licenseInfo)
- for(int l = 0; l < licenseArr.length(); l++){
- JSONObject license = licenseArr.getJSONObject(l)
- String jsonServiceResourceId = license.getString("serviceResourceId")
- for(Resource resource:resourceList){
- String serviceResourceId = resource.getResourceId()
- if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
- //match
- String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList")
- List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList)
- resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList)
+ if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){
+ String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo")
+ JSONArray licenseArr = new JSONArray(licenseInfo)
+ for(int l = 0; l < licenseArr.length(); l++){
+ JSONObject license = licenseArr.getJSONObject(l)
+ String jsonServiceResourceId = license.getString("serviceResourceId")
+ for(Resource resource:resourceList){
+ String serviceResourceId = resource.getResourceId()
+ if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
+ //match
+ String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList")
+ List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList)
+ resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList)
- String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList")
- List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList)
- resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList)
- }
- }
- }
- }
- execution.setVariable("serviceDecomposition", decomposition)
+ String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList")
+ List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList)
+ resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList)
+ }
+ }
+ }
+ }
+ execution.setVariable("serviceDecomposition", decomposition)
- logger.trace("Completed Sniro Homing Process Homing Solution")
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution")
- }
- }
+ logger.trace("Completed Sniro Homing Process Homing Solution")
+ }catch(BpmnError b){
+ throw b
+ }catch(Exception e){
+ logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution")
+ }
+ }
- /**
- * This method logs the start of DHVCreateService
- * to make debugging easier.
- *
- * @param - execution
- * @author cb645j
- */
- public String logStart(DelegateExecution execution){
- String requestId = execution.getVariable("testReqId")
- if(isBlank(requestId)){
- requestId = execution.getVariable("msoRequestId")
- }
- execution.setVariable("DHVCS_requestId", requestId)
- logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
- logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****")
- logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
- }
+ /**
+ * This method logs the start of DHVCreateService
+ * to make debugging easier.
+ *
+ * @param - execution
+ * @author cb645j
+ */
+ public String logStart(DelegateExecution execution){
+ String requestId = execution.getVariable("testReqId")
+ if(isBlank(requestId)){
+ requestId = execution.getVariable("msoRequestId")
+ }
+ execution.setVariable("DHVCS_requestId", requestId)
+ logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
+ logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****")
+ logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
+ }
- /**
- * Auto-generated method stub
- */
- public void preProcessRequest(DelegateExecution execution){}
+ /**
+ * Auto-generated method stub
+ */
+ public void preProcessRequest(DelegateExecution execution){}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index e237462..009686d 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1552,7 +1552,8 @@
}
parameter.setApplicationId(applicationId);
this.populateGenericVnf(parameter);
- } else if (bbName.contains(PNF) || bbName.equals("ControllerExecutionBB")) {
+ } else if (bbName.contains(PNF) || (bbName.contains(CONTROLLER)
+ && (PNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
String pnfId = lookupKeyMap.get(ResourceKey.PNF);
resources.getPnfs().stream()
.filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst()
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java
deleted file mode 100644
index dc5b630..0000000
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.client.appc;
-
-import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider;
-import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory;
-import org.onap.appc.client.lcm.api.ApplicationContext;
-import org.onap.appc.client.lcm.api.LifeCycleManagerStateful;
-import org.onap.appc.client.lcm.exceptions.AppcClientException;
-import org.onap.appc.client.lcm.model.*;
-import org.onap.appc.client.lcm.model.Flags.Force;
-import org.onap.appc.client.lcm.model.Flags.Mode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.time.Instant;
-import java.util.Properties;
-import java.util.UUID;
-
-@Component
-@Deprecated
-public class ApplicationControllerClientV2 {
-
- private static final String CLIENT_NAME = "MSO";
- private static final String API_VER = "2.00";
- private static final String ORIGINATOR_ID = "MSO";
- private static final int FLAGS_TTL = 65000;
- private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClientV2.class);
-
- // @Autowired
- ApplicationControllerConfiguration applicationControllerConfiguration;
-
- // @Autowired
- private ApplicationControllerSupport appCSupport;
-
- private static LifeCycleManagerStateful client;
-
- // @PostConstruct
- public void buildClient() {
- client = this.getAppCClient("");
- }
-
- // @PostConstruct
- public void buildClient(String controllerType) {
- client = this.getAppCClient(controllerType);
- }
-
- public Status runCommand(Action action, ActionIdentifiers actionIdentifiers, Payload payload, String requestID)
- throws ApplicationControllerOrchestratorException {
- Object requestObject;
- requestObject = createRequest(action, actionIdentifiers, payload, requestID);
- appCSupport.logLCMMessage(requestObject);
- Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false);
- try {
- Object response = lcmMethod.invoke(client, requestObject);
- return appCSupport.getStatusFromGenericResponse(response);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e);
- }
- }
-
- public LifeCycleManagerStateful getAppCClient(String controllerType) {
- if (client == null)
- try {
- client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class)
- .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType));
- } catch (AppcClientException e) {
- logger.error("Error in getting LifeCycleManagerStateful Client", e);
- }
- return client;
- }
-
- protected Properties getLCMProperties(String controllerType) {
- Properties properties = new Properties();
- properties.put("topic.read", applicationControllerConfiguration.getReadTopic());
- properties.put("topic.read.timeout", applicationControllerConfiguration.getReadTimeout());
- properties.put("client.response.timeout", applicationControllerConfiguration.getResponseTimeout());
- properties.put("topic.write", applicationControllerConfiguration.getWrite());
- properties.put("poolMembers", applicationControllerConfiguration.getPoolMembers());
- properties.put("client.key", applicationControllerConfiguration.getClientKey());
- properties.put("client.secret", applicationControllerConfiguration.getClientSecret());
- properties.put("client.name", CLIENT_NAME);
- properties.put("service", applicationControllerConfiguration.getService());
- return properties;
- }
-
- public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) {
- Object requestObject = appCSupport.getInput(action.name());
- try {
- CommonHeader commonHeader = buildCommonHeader(requestId);
- requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject,
- commonHeader);
- requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action);
- requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class)
- .invoke(requestObject, identifier);
- if (payload != null) {
- requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload);
- }
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- logger.error("Error building Appc request", e);
- }
- return requestObject;
- }
-
- private CommonHeader buildCommonHeader(String requestId) {
- CommonHeader commonHeader = new CommonHeader();
- commonHeader.setApiVer(API_VER);
- commonHeader.setOriginatorId(ORIGINATOR_ID);
- commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId);
- commonHeader.setSubRequestId(requestId);
- Flags flags = new Flags();
- String flagsMode = "NORMAL";
- Mode mode = Mode.valueOf(flagsMode);
- flags.setMode(mode);
- String flagsForce = "FALSE";
- Force force = Force.valueOf(flagsForce);
- flags.setForce(force);
- flags.setTtl(FLAGS_TTL);
- commonHeader.setFlags(flags);
- Instant timestamp = Instant.now();
- ZULU zulu = new ZULU(timestamp.toString());
- commonHeader.setTimestamp(zulu);
- return commonHeader;
- }
-
- public Flags createRequestFlags() {
- Flags flags = new Flags();
- flags.setTtl(6000);
- return flags;
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java
deleted file mode 100644
index b39ba5f..0000000
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.client.appc;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class ApplicationControllerConfiguration {
- @Value("${appc.client.topic.read.name}")
- private String readTopic;
-
- @Value("${appc.client.topic.read.timeout}")
- private String readTimeout;
-
- @Value("${appc.client.response.timeout}")
- private String responseTimeout;
-
- @Value("${appc.client.topic.write}")
- private String write;
-
- @Value("${appc.client.poolMembers}")
- private String poolMembers;
-
- @Value("${appc.client.key}")
- private String clientKey;
-
- @Value("${appc.client.secret}")
- private String clientSecret;
-
- @Value("${appc.client.service}")
- private String service;
-
- public String getClientKey() {
- return clientKey;
- }
-
- public String getClientSecret() {
- return clientSecret;
- }
-
- public String getPoolMembers() {
- return poolMembers;
- }
-
- public String getReadTimeout() {
- return readTimeout;
- }
-
- public String getResponseTimeout() {
- return responseTimeout;
- }
-
- public String getReadTopic() {
- return readTopic;
- }
-
- public String getService() {
- return service;
- }
-
- public String getWrite() {
- return write;
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
deleted file mode 100644
index c242017..0000000
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.client.appc;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.appc.client.lcm.model.ActionIdentifiers;
-import org.onap.appc.client.lcm.model.CheckLockInput;
-import org.onap.appc.client.lcm.model.Status;
-import org.onap.so.BaseTest;
-import java.util.Properties;
-import java.util.UUID;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ApplicationControllerClientV2Test {
-
- @Mock
- ApplicationControllerSupport applicationControllerSupport;
-
- @Mock
- ApplicationControllerConfiguration applicationControllerConfiguration;
-
- @InjectMocks
- ApplicationControllerClientV2 client;
-
-
- @Before
- public void setup() {
- when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2");
- when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000");
- when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000");
- when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3");
- when(applicationControllerConfiguration.getService()).thenReturn("ueb");
- when(applicationControllerConfiguration.getPoolMembers())
- .thenReturn("localhost:3904,localhost:3904,localhost:3904");
- when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP");
- when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz");
- // client.buildClient();
- }
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Ignore
- @Test
- public void createRequest_CheckLock_RequestBuilt() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("vnfId");
- // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput());
- CheckLockInput checkLockInput =
- (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, "requestId");
- assertEquals(checkLockInput.getAction().name(), "CheckLock");
- }
-
- @Ignore
- @Test
- public void runCommand_liveAppc() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- // actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
- actionIdentifiers.setVnfId("2d2bf10e-81a5-");
- Status status;
- // when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput());
- // when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod();
- try {
- status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 306);
- }
-
- @Ignore
- @Test
- public void runCommand_CheckLock_RequestBuilt() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
- Status status;
- try {
- status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 309);
- }
-
- @Ignore
- @Test
- public void test_getLCMPropertiesHelper() {
- Properties properties = client.getLCMProperties("");
- assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
- assertEquals(properties.get("topic.read.timeout"), "120000");
- assertEquals(properties.get("client.response.timeout"), "120000");
- assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
- assertEquals(properties.get("poolMembers"), "localhost:3904,localhost:3904,localhost:3904");
- assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
- assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
index 309b053..ddfb29e 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
@@ -37,6 +37,7 @@
private InventoryType inventoryType;
private boolean isRehome;
private String serviceInstanceId; // TODO should start using si object instead
+ private String allottedResourceId;
private String cloudOwner;
private String cloudRegionId;
private String aicClli;
@@ -74,6 +75,14 @@
this.serviceInstanceId = serviceInstanceId;
}
+ public String getAllottedResourceId() {
+ return allottedResourceId;
+ }
+
+ public void setAllottedResourceId(String allottedResourceId) {
+ this.allottedResourceId = allottedResourceId;
+ }
+
public String getCloudOwner() {
return cloudOwner;
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn
new file mode 100644
index 0000000..a1d4178
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1k6npmy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0">
+ <bpmn:process id="ServiceLevelUpgrade" name="ServiceLevelUpgrade" isExecutable="true">
+ <bpmn:startEvent id="Event_02mc8tr">
+ <bpmn:outgoing>Flow_0nrz340</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:serviceTask id="Activity_18vue7u" name="Service Upgrade Dispatcher" camunda:delegateExpression="${ServiceLevelRequestDispatcher}">
+ <bpmn:incoming>Flow_0nrz340</bpmn:incoming>
+ <bpmn:outgoing>Flow_1b392qs</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="Event_12983th">
+ <bpmn:incoming>Flow_10jgbxm</bpmn:incoming>
+ <bpmn:terminateEventDefinition id="TerminateEventDefinition_1pnutu7" />
+ </bpmn:endEvent>
+ <bpmn:exclusiveGateway id="Gateway_02fectw" default="Flow_0y1ebox">
+ <bpmn:incoming>Flow_1y3cptr</bpmn:incoming>
+ <bpmn:outgoing>Flow_0y1ebox</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0mbp7mv</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="Event_0ldlupa">
+ <bpmn:incoming>Flow_0y1ebox</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1dih7c9" errorRef="Error_01a8p43" />
+ </bpmn:endEvent>
+ <bpmn:exclusiveGateway id="Gateway_1nr51kr" default="Flow_0mxq0qe">
+ <bpmn:incoming>Flow_0trmo7s</bpmn:incoming>
+ <bpmn:outgoing>Flow_1z06yyv</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0mxq0qe</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="Event_16k9r1c">
+ <bpmn:incoming>Flow_0mxq0qe</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_042otuj" errorRef="Error_0e5owqi" />
+ </bpmn:endEvent>
+ <bpmn:exclusiveGateway id="Gateway_1vq11i7" default="Flow_1tcnzdx">
+ <bpmn:incoming>Flow_1ru18s3</bpmn:incoming>
+ <bpmn:outgoing>Flow_1tcnzdx</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0l67uzl</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="Event_03tpudy">
+ <bpmn:incoming>Flow_1tcnzdx</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_16r0jc3" errorRef="Error_04y00c4" />
+ </bpmn:endEvent>
+ <bpmn:serviceTask id="Activity_0snmatn" name="Service Level Upgrade" camunda:delegateExpression="${ServiceLevelUpgrade}">
+ <bpmn:incoming>Flow_1z06yyv</bpmn:incoming>
+ <bpmn:outgoing>Flow_01gwzx9</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_0ft7fa2" name="Service Level Postcheck" camunda:delegateExpression="${ServiceLevelPostcheck}">
+ <bpmn:incoming>Flow_05ohtnj</bpmn:incoming>
+ <bpmn:outgoing>Flow_1ru18s3</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_09bqns0" name="Service Level Preparation" camunda:delegateExpression="${ServiceLevelPreparation}">
+ <bpmn:incoming>Flow_1v0mxe7</bpmn:incoming>
+ <bpmn:outgoing>Flow_1p4xkdj</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:scriptTask id="Activity_0qgmx7a" name="Send Response" scriptFormat="groovy">
+ <bpmn:incoming>Flow_1b392qs</bpmn:incoming>
+ <bpmn:outgoing>Flow_1v0mxe7</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def pnfSwUpgrade = new PNFSoftwareUpgrade()
+pnfSwUpgrade.sendResponse(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:scriptTask id="Activity_1n4rk7m" name="Prepare Completion" scriptFormat="groovy">
+ <bpmn:incoming>Flow_0l67uzl</bpmn:incoming>
+ <bpmn:outgoing>Flow_0frhsd0</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def pnfSwUpgrade = new PNFSoftwareUpgrade()
+pnfSwUpgrade.prepareCompletion(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:callActivity id="Activity_1lz38px" name="Complete Process" calledElement="CompleteMsoProcess">
+ <bpmn:incoming>Flow_0frhsd0</bpmn:incoming>
+ <bpmn:outgoing>Flow_10jgbxm</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:subProcess id="Activity_0ui6tp1" name="Subprocess for FalloutHandler" triggeredByEvent="true">
+ <bpmn:startEvent id="Event_08f3m9h">
+ <bpmn:outgoing>Flow_0iayg6u</bpmn:outgoing>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1d67w55" />
+ </bpmn:startEvent>
+ <bpmn:scriptTask id="Activity_1k2f3ha" name="Prepare FalloutHandler" scriptFormat="groovy">
+ <bpmn:incoming>Flow_0iayg6u</bpmn:incoming>
+ <bpmn:outgoing>Flow_0lb7zv5</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def pnfSwUpgrade = new PNFSoftwareUpgrade()
+pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:callActivity id="Activity_0ai3z2q" name="Call FalloutHandler" calledElement="FalloutHandler">
+ <bpmn:incoming>Flow_0lb7zv5</bpmn:incoming>
+ <bpmn:outgoing>Flow_1peoyur</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:endEvent id="Event_0ngb9wx">
+ <bpmn:incoming>Flow_1peoyur</bpmn:incoming>
+ <bpmn:terminateEventDefinition id="TerminateEventDefinition_1e5scwm" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_1peoyur" sourceRef="Activity_0ai3z2q" targetRef="Event_0ngb9wx" />
+ <bpmn:sequenceFlow id="Flow_0lb7zv5" sourceRef="Activity_1k2f3ha" targetRef="Activity_0ai3z2q" />
+ <bpmn:sequenceFlow id="Flow_0iayg6u" sourceRef="Event_08f3m9h" targetRef="Activity_1k2f3ha" />
+ </bpmn:subProcess>
+ <bpmn:sequenceFlow id="Flow_0nrz340" sourceRef="Event_02mc8tr" targetRef="Activity_18vue7u" />
+ <bpmn:sequenceFlow id="Flow_1b392qs" sourceRef="Activity_18vue7u" targetRef="Activity_0qgmx7a" />
+ <bpmn:sequenceFlow id="Flow_10jgbxm" sourceRef="Activity_1lz38px" targetRef="Event_12983th" />
+ <bpmn:sequenceFlow id="Flow_01gwzx9" sourceRef="Activity_0snmatn" targetRef="Activity_1q4o9fx" />
+ <bpmn:sequenceFlow id="Flow_0y1ebox" name="Failure" sourceRef="Gateway_02fectw" targetRef="Event_0ldlupa" />
+ <bpmn:sequenceFlow id="Flow_1p4xkdj" sourceRef="Activity_09bqns0" targetRef="Activity_0n17xou" />
+ <bpmn:sequenceFlow id="Flow_1z06yyv" name="Success" sourceRef="Gateway_1nr51kr" targetRef="Activity_0snmatn">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="Flow_0mxq0qe" name="Failure" sourceRef="Gateway_1nr51kr" targetRef="Event_16k9r1c" />
+ <bpmn:sequenceFlow id="Flow_1ru18s3" sourceRef="Activity_0ft7fa2" targetRef="Gateway_1vq11i7" />
+ <bpmn:sequenceFlow id="Flow_1tcnzdx" name="Failure" sourceRef="Gateway_1vq11i7" targetRef="Event_03tpudy" />
+ <bpmn:sequenceFlow id="Flow_0l67uzl" name="Success" sourceRef="Gateway_1vq11i7" targetRef="Activity_1n4rk7m">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="Flow_1v0mxe7" sourceRef="Activity_0qgmx7a" targetRef="Activity_09bqns0" />
+ <bpmn:sequenceFlow id="Flow_0frhsd0" sourceRef="Activity_1n4rk7m" targetRef="Activity_1lz38px" />
+ <bpmn:sequenceFlow id="Flow_0mbp7mv" name="Success" sourceRef="Gateway_02fectw" targetRef="Activity_1hp67qz">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:callActivity id="Activity_0n17xou" name="BPMN to Execute" calledElement="${healthCheckWorkflow}">
+ <bpmn:extensionElements>
+ <camunda:in source="bpmnRequest" target="bpmnRequest" />
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="msoRequestId" target="msoRequestId" />
+ <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" />
+ <camunda:out source="ControllerStatus" target="ControllerStatus" />
+ <camunda:in source="isRollback" target="isRollback" />
+ <camunda:in source="pnfName" target="pnfName" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>Flow_1p4xkdj</bpmn:incoming>
+ <bpmn:outgoing>Flow_0trmo7s</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:sequenceFlow id="Flow_0trmo7s" sourceRef="Activity_0n17xou" targetRef="Gateway_1nr51kr" />
+ <bpmn:callActivity id="Activity_1q4o9fx" name="BPMN to Execute" calledElement="${softwareUpgradeWorkflow}">
+ <bpmn:extensionElements>
+ <camunda:in source="bpmnRequest" target="bpmnRequest" />
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="msoRequestId" target="msoRequestId" />
+ <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" />
+ <camunda:out source="ControllerStatus" target="ControllerStatus" />
+ <camunda:in source="isRollback" target="isRollback" />
+ <camunda:in source="pnfName" target="pnfName" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>Flow_01gwzx9</bpmn:incoming>
+ <bpmn:outgoing>Flow_1y3cptr</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:sequenceFlow id="Flow_1y3cptr" sourceRef="Activity_1q4o9fx" targetRef="Gateway_02fectw" />
+ <bpmn:serviceTask id="Activity_1hp67qz" name="Update ServiceInstance To AAI" camunda:delegateExpression="${UpdateServiceInstanceInAai}">
+ <bpmn:incoming>Flow_0mbp7mv</bpmn:incoming>
+ <bpmn:outgoing>Flow_0dyc3kv</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0dyc3kv" sourceRef="Activity_1hp67qz" targetRef="Gateway_18ch73t" />
+ <bpmn:exclusiveGateway id="Gateway_18ch73t" default="Flow_0ny61qm">
+ <bpmn:incoming>Flow_0dyc3kv</bpmn:incoming>
+ <bpmn:outgoing>Flow_05ohtnj</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0ny61qm</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_05ohtnj" name="Success " sourceRef="Gateway_18ch73t" targetRef="Activity_0ft7fa2">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:endEvent id="Event_1fhov6x">
+ <bpmn:incoming>Flow_0ny61qm</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0od3xnw" errorRef="Error_01a8p43" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0ny61qm" name="Failure " sourceRef="Gateway_18ch73t" targetRef="Event_1fhov6x" />
+ </bpmn:process>
+ <bpmn:error id="Error_01a8p43" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmn:error id="Error_0e5owqi" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmn:error id="Error_1at4rzq" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmn:error id="Error_04y00c4" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ServiceLevelUpgrade">
+ <bpmndi:BPMNEdge id="Flow_0ny61qm_di" bpmnElement="Flow_0ny61qm">
+ <di:waypoint x="1190" y="278" />
+ <di:waypoint x="1190" y="334" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1152" y="290" width="35" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_05ohtnj_di" bpmnElement="Flow_05ohtnj">
+ <di:waypoint x="1206" y="262" />
+ <di:waypoint x="1300" y="262" />
+ <di:waypoint x="1300" y="372" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1232" y="244" width="43" height="40" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0dyc3kv_di" bpmnElement="Flow_0dyc3kv">
+ <di:waypoint x="1120" y="262" />
+ <di:waypoint x="1174" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1y3cptr_di" bpmnElement="Flow_1y3cptr">
+ <di:waypoint x="860" y="262" />
+ <di:waypoint x="904" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0trmo7s_di" bpmnElement="Flow_0trmo7s">
+ <di:waypoint x="450" y="262" />
+ <di:waypoint x="501" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0mbp7mv_di" bpmnElement="Flow_0mbp7mv">
+ <di:waypoint x="936" y="262" />
+ <di:waypoint x="1020" y="262" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="948" y="248" width="43" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0frhsd0_di" bpmnElement="Flow_0frhsd0">
+ <di:waypoint x="312" y="482" />
+ <di:waypoint x="372" y="482" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1v0mxe7_di" bpmnElement="Flow_1v0mxe7">
+ <di:waypoint x="532" y="122" />
+ <di:waypoint x="562" y="122" />
+ <di:waypoint x="562" y="192" />
+ <di:waypoint x="172" y="192" />
+ <di:waypoint x="172" y="262" />
+ <di:waypoint x="212" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0l67uzl_di" bpmnElement="Flow_0l67uzl">
+ <di:waypoint x="1054" y="412" />
+ <di:waypoint x="172" y="412" />
+ <di:waypoint x="172" y="482" />
+ <di:waypoint x="212" y="482" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="663" y="398" width="43" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1tcnzdx_di" bpmnElement="Flow_1tcnzdx">
+ <di:waypoint x="1070" y="428" />
+ <di:waypoint x="1070" y="494" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1032" y="451" width="35" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1ru18s3_di" bpmnElement="Flow_1ru18s3">
+ <di:waypoint x="1250" y="412" />
+ <di:waypoint x="1086" y="412" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0mxq0qe_di" bpmnElement="Flow_0mxq0qe">
+ <di:waypoint x="517" y="278" />
+ <di:waypoint x="517" y="334" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="472" y="296" width="35" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1z06yyv_di" bpmnElement="Flow_1z06yyv">
+ <di:waypoint x="533" y="262" />
+ <di:waypoint x="590" y="262" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="540" y="248" width="43" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1p4xkdj_di" bpmnElement="Flow_1p4xkdj">
+ <di:waypoint x="312" y="262" />
+ <di:waypoint x="350" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0y1ebox_di" bpmnElement="Flow_0y1ebox">
+ <di:waypoint x="920" y="278" />
+ <di:waypoint x="918" y="335" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="879" y="296" width="35" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_01gwzx9_di" bpmnElement="Flow_01gwzx9">
+ <di:waypoint x="690" y="262" />
+ <di:waypoint x="760" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_10jgbxm_di" bpmnElement="Flow_10jgbxm">
+ <di:waypoint x="472" y="482" />
+ <di:waypoint x="524" y="480" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1b392qs_di" bpmnElement="Flow_1b392qs">
+ <di:waypoint x="362" y="122" />
+ <di:waypoint x="432" y="122" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0nrz340_di" bpmnElement="Flow_0nrz340">
+ <di:waypoint x="186" y="120" />
+ <di:waypoint x="262" y="122" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_02mc8tr_di" bpmnElement="Event_02mc8tr">
+ <dc:Bounds x="154" y="104" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-6" y="-188" width="51" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_18vue7u_di" bpmnElement="Activity_18vue7u">
+ <dc:Bounds x="262" y="82" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_12983th_di" bpmnElement="Event_12983th">
+ <dc:Bounds x="524" y="464" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-132" y="-188" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_02fectw_di" bpmnElement="Gateway_02fectw" isMarkerVisible="true">
+ <dc:Bounds x="904" y="246" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0ldlupa_di" bpmnElement="Event_0ldlupa">
+ <dc:Bounds x="905" y="334" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1nr51kr_di" bpmnElement="Gateway_1nr51kr" isMarkerVisible="true">
+ <dc:Bounds x="501" y="246" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_16k9r1c_di" bpmnElement="Event_16k9r1c">
+ <dc:Bounds x="501" y="334" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1vq11i7_di" bpmnElement="Gateway_1vq11i7" isMarkerVisible="true">
+ <dc:Bounds x="1054" y="396" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_03tpudy_di" bpmnElement="Event_03tpudy">
+ <dc:Bounds x="1054" y="494" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0snmatn_di" bpmnElement="Activity_0snmatn">
+ <dc:Bounds x="590" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0ft7fa2_di" bpmnElement="Activity_0ft7fa2">
+ <dc:Bounds x="1250" y="372" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_09bqns0_di" bpmnElement="Activity_09bqns0">
+ <dc:Bounds x="212" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0qgmx7a_di" bpmnElement="Activity_0qgmx7a">
+ <dc:Bounds x="432" y="82" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1n4rk7m_di" bpmnElement="Activity_1n4rk7m">
+ <dc:Bounds x="212" y="442" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1lz38px_di" bpmnElement="Activity_1lz38px">
+ <dc:Bounds x="372" y="442" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0ui6tp1_di" bpmnElement="Activity_0ui6tp1" isExpanded="true">
+ <dc:Bounds x="362" y="572" width="650" height="190" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_0iayg6u_di" bpmnElement="Flow_0iayg6u">
+ <di:waypoint x="466" y="670" />
+ <di:waypoint x="532" y="672" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0lb7zv5_di" bpmnElement="Flow_0lb7zv5">
+ <di:waypoint x="632" y="672" />
+ <di:waypoint x="702" y="672" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1peoyur_di" bpmnElement="Flow_1peoyur">
+ <di:waypoint x="802" y="672" />
+ <di:waypoint x="874" y="670" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_08f3m9h_di" bpmnElement="Event_08f3m9h">
+ <dc:Bounds x="434" y="654" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-161" y="-188" width="78" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1k2f3ha_di" bpmnElement="Activity_1k2f3ha">
+ <dc:Bounds x="532" y="632" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0ai3z2q_di" bpmnElement="Activity_0ai3z2q">
+ <dc:Bounds x="702" y="632" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0ngb9wx_di" bpmnElement="Event_0ngb9wx">
+ <dc:Bounds x="874" y="654" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-132" y="-188" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0n17xou_di" bpmnElement="Activity_0n17xou">
+ <dc:Bounds x="350" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1q4o9fx_di" bpmnElement="Activity_1q4o9fx">
+ <dc:Bounds x="760" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1hp67qz_di" bpmnElement="Activity_1hp67qz">
+ <dc:Bounds x="1020" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_18ch73t_di" bpmnElement="Gateway_18ch73t" isMarkerVisible="true">
+ <dc:Bounds x="1174" y="246" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_1fhov6x_di" bpmnElement="Event_1fhov6x">
+ <dc:Bounds x="1174" y="334" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java
new file mode 100644
index 0000000..00dda29
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java
@@ -0,0 +1,259 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
+import com.google.protobuf.Struct;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aaiclient.client.aai.AAIVersion;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.so.BaseBPMNTest;
+import org.onap.so.GrpcNettyServer;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames;
+import org.onap.so.bpmn.mock.FileUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Basic Integration test for ServiceLevelUpgrade.bpmn workflow.
+ */
+public class ServiceLevelUpgradeTest extends BaseBPMNTest {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private static final long WORKFLOW_WAIT_TIME = 1000L;
+
+ private static final String TEST_PROCESSINSTANCE_KEY = "ServiceLevelUpgrade";
+ private static final AAIVersion VERSION = AAIVersion.LATEST;
+ private static final Map<String, Object> executionVariables = new HashMap();
+ private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5";
+ private static final String SERVICE_INSTANCE_ID = "5df8b6de-2083-11e7-93ae-92361f002676";
+ private final String[] actionNames = new String[5];
+ private final String CLASSNAME = getClass().getSimpleName();
+ private String requestObject;
+ private String responseObject;
+
+ @Autowired
+ private GrpcNettyServer grpcNettyServer;
+
+ @Before
+ public void setUp() throws IOException {
+ actionNames[0] = "healthCheck";
+ actionNames[1] = "preCheck";
+ actionNames[2] = "downloadNESw";
+ actionNames[3] = "activateNESw";
+ actionNames[4] = "postCheck";
+
+ executionVariables.clear();
+
+ requestObject = FileUtil.readResourceFile("request/" + CLASSNAME + ".json");
+ responseObject = FileUtil.readResourceFile("response/" + CLASSNAME + ".json");
+
+ executionVariables.put("bpmnRequest", requestObject);
+ executionVariables.put("requestId", REQUEST_ID);
+ executionVariables.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+
+
+ /**
+ * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}.
+ */
+ executionVariables.put("isAsyncProcess", "true");
+ executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680");
+
+ /**
+ * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api
+ * handler and then convert to CamudaInput
+ */
+ executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo");
+ }
+
+
+ @Test
+ public void workflow_validInput_expectedOutput() throws InterruptedException {
+
+ mockCatalogDb();
+ mockRequestDb();
+ mockAai();
+
+ final String msoRequestId = UUID.randomUUID().toString();
+ executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
+
+ final String testBusinessKey = UUID.randomUUID().toString();
+ logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
+
+ ProcessInstance pi =
+ runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
+
+ int waitCount = 10;
+ while (!isProcessInstanceEnded() && waitCount >= 0) {
+ Thread.sleep(WORKFLOW_WAIT_TIME);
+ waitCount--;
+ }
+
+ // Layout is to reflect the bpmn visual layout
+ assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_0qgmx7a",
+ "Activity_09bqns0", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_1q4o9fx",
+ "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7",
+ "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th");
+
+ List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
+ assertThat(detailedMessages.size() == 5);
+ int count = 0;
+ try {
+ for (ExecutionServiceInput eSI : detailedMessages) {
+ for (String action : actionNames) {
+ if (action.equals(eSI.getActionIdentifiers().getActionName())
+ && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
+ checkWithActionName(eSI, action);
+ count++;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("PNFSoftwareUpgrade request exception", e);
+ }
+ assertThat(count == actionNames.length);
+ }
+
+ private boolean isProcessInstanceEnded() {
+ return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY)
+ .singleResult() == null;
+ }
+
+ private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) {
+
+ logger.info("Checking the " + action + " request");
+ ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+
+ /**
+ * the fields of actionIdentifiers should match the one in the response/PnfHealthCheck_catalogdb.json.
+ */
+ assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf");
+ assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0");
+ assertThat(actionIdentifiers.getActionName()).isEqualTo(action);
+ assertThat(actionIdentifiers.getMode()).isEqualTo("async");
+
+ CommonHeader commonHeader = executionServiceInput.getCommonHeader();
+ assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
+
+ Struct payload = executionServiceInput.getPayload();
+ Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue();
+
+ assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo");
+ Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue();
+
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo");
+ assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue())
+ .isEqualTo("d88da85c-d9e8-4f73-b837-3a72a431622b");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
+ .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680");
+ }
+
+ private void mockAai() {
+
+ final String sIUrl =
+ "/business/customers/customer/5df8b6de-2083-11e7-93ae-92361f002676/service-subscriptions/service-subscription/pNF/service-instances/service-instance/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce";
+ final String aaiPnfEntry = FileUtil.readResourceFile("response/Pnf_aai.json");
+ final String aaiServiceInstanceEntry = FileUtil.readResourceFile("response/Service_instance_aai.json");
+
+ /**
+ * PUT the PNF correlation ID to AAI.
+ */
+ wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")));
+
+ /**
+ * Get the PNF entry from AAI.
+ */
+ wireMockServer.stubFor(
+ get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry)));
+
+ /**
+ * Post the pnf to AAI
+ */
+ wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")));
+
+ /**
+ * Get the Service Instance to AAI.
+ */
+ wireMockServer.stubFor(get(urlEqualTo("/aai/" + VERSION + sIUrl)).willReturn(okJson(aaiServiceInstanceEntry)));
+
+ /**
+ * Post the Service Instance to AAI.
+ */
+ wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + sIUrl)));
+ }
+
+ private void mockRequestDb() {
+ /**
+ * Update Request DB
+ */
+ wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID)));
+
+ }
+
+ /**
+ * Mock the catalobdb rest interface.
+ */
+ private void mockCatalogDb() {
+
+ String catalogdbClientResponse = FileUtil.readResourceFile("response/" + CLASSNAME + "_catalogdb.json");
+
+
+ /**
+ * Return valid json for the model UUID in the request file.
+ */
+ wireMockServer
+ .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=d88da85c-d9e8-4f73-b837-3a72a431622b"))
+ .willReturn(okJson(responseObject)));
+
+ /**
+ * Return valid json for the service model InvariantUUID as specified in the request file.
+ */
+ wireMockServer.stubFor(
+ get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=fe41489e-1563-46a3-b90a-1db629e4375b"))
+ .willReturn(okJson(responseObject)));
+
+ /**
+ * Return valid spring data rest json for the service model UUID as specified in the request file.
+ */
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=d88da85c-d9e8-4f73-b837-3a72a431622b"))
+ .willReturn(okJson(catalogdbClientResponse)));
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json
new file mode 100644
index 0000000..b5cce60
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json
@@ -0,0 +1,48 @@
+{
+ "requestDetails":{
+ "subscriberInfo":{
+ "globalSubscriberId":"ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"
+ },
+ "requestInfo":{
+ "suppressRollback": false,
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "demo",
+ "instanceName":"testInstanceName",
+ "source":"VID"
+ },
+ "cloudConfiguration":{
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f",
+ "cloudOwner": "CloudOwner"
+ },
+ "requestParameters":{
+ "subscriptionServiceType": "pNF",
+ "userParams":[
+ {
+ "name":"targetSoftwareVersion",
+ "value":"demo-sw-ver2.0.0"
+ },
+ {
+ "name":"pnfName",
+ "value":"PNFDemo"
+ }
+ ],
+ "aLaCarte": false,
+ "payload": "{\"k1\": \"v1\"}"
+ },
+ "project":{
+ "projectName": "ServiceLevelUpgrade"
+ },
+ "owningEntity":{
+ "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "owningEntityName":"OE-Test"
+ },
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ }
+ }
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json
new file mode 100644
index 0000000..865600c
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json
@@ -0,0 +1,42 @@
+{
+ "pnf-name": "PNFDemo",
+ "pnf-id": "27c6e19d-6d9f-4085-98a9-d3fcbaf3a616",
+ "equip-type": "val8",
+ "equip-vendor": "Ericsson",
+ "equip-model": "val6",
+ "ipaddress-v4-oam": "10.10.10.43",
+ "sw-version": "5gDUv18.05.201",
+ "in-maint": false,
+ "serial-number": "6061ZW3",
+ "ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
+ "resource-version": "1595010038094",
+ "nf-role": "gNB",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce/service-subscriptions/service-subscription/pNF/service-instances/service-instance/5df8b6de-2083-11e7-93ae-92361f002676",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "pNF"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5df8b6de-2083-11e7-93ae-92361f002676"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269"
+ }
+ ]
+ }
+ ]
+ }
+},
\ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json
new file mode 100644
index 0000000..ec92552
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json
@@ -0,0 +1,27 @@
+{
+ "serviceResources":{
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ },
+ "serviceType":"pNF",
+ "environmentContext":"Luna",
+ "serviceRole":"NA",
+ "workloadContext":"Oxygen",
+ "serviceVnfs":[
+
+ ],
+ "serviceNetworks":[
+
+ ],
+ "serviceAllottedResources":[
+
+ ],
+ "configResource":[
+
+ ]
+ }
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json
new file mode 100644
index 0000000..faec947
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json
@@ -0,0 +1,39 @@
+{
+ "_embedded": {
+ "pnfResourceCustomization": [
+ {
+ "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680",
+ "modelInstanceName": "PNF routing",
+ "created": "2019-03-08 12:00:29.000",
+ "nfFunction": "routing",
+ "nfType": "routing",
+ "nfRole": "routing",
+ "nfNamingCode": "routing",
+ "multiStageDesign": null,
+ "resourceInput": null,
+ "blueprintName": "test_pnf_software_upgrade_restconf",
+ "blueprintVersion": "1.0.0",
+ "skipPostInstConf": false,
+ "softwareVersion": "1.0.0",
+ "creationTimestamp": "2019-03-08T12:00:29.000+0000",
+ "controllerActor": "cds",
+ "_links": {
+ "self": {
+ "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680"
+ },
+ "pnfResourceCustomization": {
+ "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680"
+ },
+ "pnfResources": {
+ "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources"
+ }
+ }
+ }
+ ]
+ },
+ "_links": {
+ "self": {
+ "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676"
+ }
+ }
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json
new file mode 100644
index 0000000..53fb210
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json
@@ -0,0 +1,35 @@
+{
+ "service-instance-id": "5df8b6de-2083-11e7-93ae-92361f002676",
+ "service-instance-name": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-version-id": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "resource-version": "1595258335377",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/5df8b6de-2083-11e7-93ae-92361f002676/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java
similarity index 60%
rename from bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java
rename to bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java
index 36db549..e261951 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java
@@ -20,40 +20,58 @@
package org.onap.so.bpmn.infrastructure.service.level;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.List;
/**
- * Abstract class for Service level upgrade Execution, it should be extended for service level upgrade tasks.
+ * Parent class for Service level upgrade Execution, it should be extended for service level upgrade tasks.
*/
-public abstract class AbstractServiceLevelPreparable {
+public class ServiceLevelPreparable {
- protected static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow";
- protected static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck";
- protected static final String GENERIC_PNF_SOFTWARE_UPGRADE_WORKFLOW = "GenericPnfSoftwareUpgrade";
- protected static final String RESOURCE_TYPE = "RESOURCE_TYPE";
- protected static final int ERROR_CODE = 601;
-
- // TODO This value needs to be updated once vnf health check workflow is available
- protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck";
-
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceLevelPreparable.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(ServiceLevelPreparable.class);
@Autowired
protected ExceptionBuilder exceptionBuilder;
+ @Autowired
+ protected CatalogDbClient catalogDbClient;
+
/**
- * This method fetches workflow names to be invoked based on the controller scope .
+ * Fetches workflow names based on the controller scope and operation name.
*
* @param scope Controller scope
+ * @param operationName healthcheck/softwareUpgrade
* @return String value of Workflow name
*/
- protected abstract String fetchWorkflowUsingScope(DelegateExecution execution, final String scope);
+ protected String fetchWorkflowUsingScope(final String scope, String operationName) {
+ Optional<String> wflName = Optional.empty();
+ try {
+ List<Workflow> workflows = catalogDbClient.findWorkflowByOperationName(operationName);
+ if (!workflows.isEmpty()) {
+ wflName = Optional.ofNullable(
+ workflows.stream().filter(workflow -> workflow.getResourceTarget().equalsIgnoreCase(scope))
+ .findFirst().get().getName());
+ }
+ } catch (Exception e) {
+ // do nothing and assign the default workflow in finally
+ LOG.error("Error occurred while fetching workflow name from CatalogDb {}", e);
+ } finally {
+ if (wflName.isEmpty()) {
+ wflName = Optional.of(ServiceLevelConstants.WORKFLOW_OPERATIONS_MAP.get(operationName).get(scope));
+ }
+ }
+ return wflName.get();
+
+ }
/**
* This method validates the execution parameters to be passed for health check workflow.
@@ -61,8 +79,7 @@
* @param execution Delegate execution obj
* @param scope Controller scope * Throws workflow exception if validation fails
*/
- protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params)
- throws Exception {
+ protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params) {
List<String> invalidVariables = new ArrayList<>();
for (String param : params) {
if (!execution.hasVariable(param) || execution.getVariable(param) == null
@@ -72,7 +89,7 @@
}
if (invalidVariables.size() > 0) {
LOG.error("Validation error for the {} health check attributes: {}", scope, invalidVariables);
- exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE,
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
"Validation of health check workflow parameters failed for the scope: " + scope);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
new file mode 100644
index 0000000..d946418
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+public class ServiceLevelConstants {
+ public static final String BPMN_REQUEST = "bpmnRequest";
+ public static final String RESOURCE_TYPE = "resourceType";
+ public static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ public static final String PNF_NAME = "pnfName";
+ public static final String PNF = "pnf";
+ public static final String VNF = "vnf";
+ public static final String EMPTY_STRING = "";
+ public static final String HEALTH_CHECK_WORKFLOW_TO_INVOKE = "healthCheckWorkflow";
+ public static final String SOFTWARE_WORKFLOW_TO_INVOKE = "softwareUpgradeWorkflow";
+ public static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck";
+ public static final String SW_UP_OPERATION = "ResourceSoftwareUpgrade";
+ public static final String CONTROLLER_STATUS = "ControllerStatus";
+ public static final int ERROR_CODE = 601;
+
+ // TODO GenericVNFHealthCheck and GenericVnfSoftwareUpgrade workflow names should be updated once the workflow is
+ // implemented.
+ public static final Map<String, String> DEFAULT_HEALTH_CHECK_WORKFLOWS =
+ Map.of(PNF, "GenericPnfHealthCheck", VNF, "GenericVNFHealthCheck");
+
+ public static final Map<String, String> DEFAULT_SOFTWARE_UP_WORKFLOWS =
+ Map.of(PNF, "PNFSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade");
+
+ // Maps operation name with workflows
+ public static final Map<String, Map<String, String>> WORKFLOW_OPERATIONS_MAP = Map.of(HEALTH_CHECK_OPERATION,
+ DEFAULT_HEALTH_CHECK_WORKFLOWS, SW_UP_OPERATION, DEFAULT_SOFTWARE_UP_WORKFLOWS);
+
+ public static final List<String> VALID_CONTROLLER_SCOPE = Arrays.asList(PNF, VNF);
+
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
new file mode 100644
index 0000000..fad28e3
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
@@ -0,0 +1,13 @@
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLevelPostcheck implements JavaDelegate {
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ // TODO : Set serviceInstance to aai
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
index 52521ce..59884ec 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
@@ -20,12 +20,14 @@
package org.onap.so.bpmn.infrastructure.service.level.impl;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable;
+import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable;
import org.springframework.stereotype.Component;
-import java.util.Arrays;
-import java.util.List;
/**
@@ -33,45 +35,39 @@
* validation.
*/
@Component("ServiceLevelPreparation")
-public class ServiceLevelPreparation extends AbstractServiceLevelPreparable implements JavaDelegate {
+public class ServiceLevelPreparation extends ServiceLevelPreparable implements JavaDelegate {
- // Health check parameters to be validated for pnf resource
- private static final List<String> PNF_HC_PARAMS = Arrays.asList("SERVICE_MODEL_INFO", "SERVICE_INSTANCE_NAME",
- "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME", "PRC_BLUEPRINT_VERSION",
- "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME", "PRC_CONTROLLER_ACTOR",
- "REQUEST_PAYLOAD");
+ private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID,
+ ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME);
+
+ // TODO Update the list with vnf health check parameters if any validation needed
+ private static final List<String> VNF_HEALTH_CHECK_PARAMS = Collections.emptyList();
+
+ private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF,
+ PNF_HEALTH_CHECK_PARAMS, ServiceLevelConstants.VNF, VNF_HEALTH_CHECK_PARAMS);
@Override
public void execute(DelegateExecution execution) throws Exception {
- if (execution.hasVariable(RESOURCE_TYPE) && execution.getVariable(RESOURCE_TYPE) != null) {
- final String controllerScope = (String) execution.getVariable(RESOURCE_TYPE);
+ if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
+ && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
+ final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
LOG.debug("Scope retrieved from delegate execution: " + controllerScope);
- final String wflName = fetchWorkflowUsingScope(execution, controllerScope);
- LOG.debug("Health check workflow fetched for the scope: {}", wflName);
- validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS);
- LOG.info("Parameters validated successfully for {}", wflName);
- execution.setVariable(WORKFLOW_TO_INVOKE, wflName);
+ if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) {
+ final String wflName =
+ fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.HEALTH_CHECK_OPERATION);
+ LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName);
+ validateParamsWithScope(execution, controllerScope, HEALTH_CHECK_PARAMS_MAP.get(controllerScope));
+ LOG.info("Parameters validated successfully for {}", wflName);
+ execution.setVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE, wflName);
+ execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING);
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Invalid Controller scope to prepare resource level health check");
+ }
} else {
- exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE,
- "Controller scope not found to invoke resource level health check");
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Resource type not found in the execution to invoke resource level health check");
}
}
- @Override
- public String fetchWorkflowUsingScope(DelegateExecution execution, final String scope) {
- String wflName = null;
- switch (scope.toLowerCase()) {
- case "pnf":
- wflName = GENERIC_PNF_HEALTH_CHECK_WORKFLOW;
- break;
- case "vnf":
- wflName = GENERIC_VNF_HEALTH_CHECK_WORKFLOW;
- break;
- default:
- exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE,
- "No valid health check work flow retrieved for the scope: " + scope);
- }
- return wflName;
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
new file mode 100644
index 0000000..5b20a86
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.AAIRestClientI;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+
+/**
+ * This implementation of {@link JavaDelegate} is used to populate the execution object for Service level upgrade
+ */
+@Component
+public class ServiceLevelRequestDispatcher implements JavaDelegate {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private ObjectMapper mapper;
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
+ delegateExecution.getCurrentActivityName());
+
+ RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
+
+ final String serviceInstanceId = String.valueOf(delegateExecution.getVariable(SERVICE_INSTANCE_ID));
+ final String serviceType = bpmnRequestDetails.getRequestParameters().getSubscriptionServiceType();
+ final String globalSubscriberId = bpmnRequestDetails.getSubscriberInfo().getGlobalSubscriberId();
+
+ final String modelInvariantId = bpmnRequestDetails.getModelInfo().getModelInvariantId();
+ final String modelId = bpmnRequestDetails.getModelInfo().getModelUuid();
+ final String modelVersion = bpmnRequestDetails.getModelInfo().getModelVersion();
+
+ if (ServiceLevelConstants.PNF.equalsIgnoreCase(serviceType)) {
+ getAndSetPnfNameFromServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, delegateExecution);
+ }
+
+ // TODO : handling for vnf
+
+ logger.trace("Completed dispatcher request for ServiceLevelUpgrade.");
+ }
+
+ private void getAndSetPnfNameFromServiceInstance(final String serviceInstanceId, final String serviceType,
+ final String globalSubscriberId, DelegateExecution delegateExecution) {
+
+ AAIRestClientI restClient = new AAIRestClientImpl();
+
+ Optional<ServiceInstance> optionalSi =
+ restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
+
+ if (!optionalSi.isPresent()) {
+
+ }
+
+ optionalSi.ifPresentOrElse(serviceInstance -> {
+ final String pnfName = serviceInstance.getRelationshipList().getRelationship().stream()
+ .filter(x -> x.getRelatedTo().contains("pnf")).findFirst().get().getRelationshipData().stream()
+ .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).findFirst().get()
+ .getRelationshipValue();
+ if (pnfName == null || pnfName.isEmpty()) {
+ logger.warn(
+ "Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId());
+ return;
+ }
+ delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfName);
+ delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF);
+ }, () -> {
+ throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
+ });
+ }
+
+ private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException {
+ RequestDetails bpmnRequestDetails = mapper.readValue(JsonUtils.getJsonValue(
+ String.valueOf(delegateExecution.getVariable(ServiceLevelConstants.BPMN_REQUEST)), "requestDetails"),
+ RequestDetails.class);
+
+ throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO);
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams");
+
+ return bpmnRequestDetails;
+ }
+
+ private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) {
+ if (obj == null) {
+ throwExceptionWithWarn(delegateExecution,
+ "Unable to find the parameter: " + param + " in the execution context");
+ }
+ }
+
+ private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) {
+ logger.warn(exceptionMsg);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ServiceLevelConstants.ERROR_CODE, exceptionMsg);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
new file mode 100644
index 0000000..9d7d8ef
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLevelUpgrade extends ServiceLevelPreparable implements JavaDelegate {
+
+ private static final List<String> PNF_SOFTWARE_UP_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID,
+ ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME);
+
+ // TODO Update the list with vnf software upgrade parameters if any validation needed
+ private static final List<String> VNF_SOFTWARE_UP_PARAMS = Collections.emptyList();
+
+ private static final Map<String, List<String>> SOFTWARE_UP_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF,
+ PNF_SOFTWARE_UP_PARAMS, ServiceLevelConstants.VNF, VNF_SOFTWARE_UP_PARAMS);
+
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
+ && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
+ final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
+ LOG.debug("Scope retrieved from delegate execution: " + controllerScope);
+ if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) {
+ final String wflName = fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.SW_UP_OPERATION);
+ LOG.debug("Software Upgrade workflow fetched for the scope: {} is: {}", controllerScope, wflName);
+ validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope));
+ LOG.info("Parameters validated successfully for {}", wflName);
+ execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName);
+ execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, "");
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Invalid Controller scope for resource level software upgrade");
+ }
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Resource type not found in the execution to invoke resource level software upgrade");
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java
new file mode 100644
index 0000000..c9bd607
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.AAIRestClientI;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO;
+
+@Component
+public class UpdateServiceInstanceInAai implements JavaDelegate {
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private static final String BPMN_REQUEST = "bpmnRequest";
+ private static final String PNF_RESOURCE = "pnf";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+
+ // ERROR CODE for variable not found in the delegation Context
+ private static final int ERROR_CODE = 601;
+
+ @Autowired
+ private ObjectMapper mapper;
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
+ delegateExecution.getCurrentActivityName());
+
+ RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
+
+ final String serviceInstanceId = String.valueOf(delegateExecution.getVariable(SERVICE_INSTANCE_ID));
+ final String serviceType = bpmnRequestDetails.getRequestParameters().getSubscriptionServiceType();
+ final String globalSubscriberId = bpmnRequestDetails.getSubscriberInfo().getGlobalSubscriberId();
+
+ final String modelId = bpmnRequestDetails.getModelInfo().getModelUuid();
+
+ if (PNF_RESOURCE.equalsIgnoreCase(serviceType)) {
+ getAndSetServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, modelId);
+ }
+
+ // TODO : handling for vnf
+
+ logger.trace("Completed updating request for ServiceLevelUpgrade.");
+ }
+
+ private void getAndSetServiceInstance(final String serviceInstanceId, final String serviceType,
+ final String globalSubscriberId, String modelVersionId) {
+
+ AAIRestClientI restClient = new AAIRestClientImpl();
+
+ Optional<ServiceInstance> optionalSi =
+ restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
+
+ if (!optionalSi.isPresent()) {
+ // throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
+ }
+
+ ServiceInstance serviceInstance = optionalSi.get();
+
+ serviceInstance.setModelVersionId(modelVersionId);
+
+ restClient.updateServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, serviceInstance);
+
+ }
+
+ private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException {
+ RequestDetails bpmnRequestDetails = mapper.readValue(
+ JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"),
+ RequestDetails.class);
+
+ throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO);
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams");
+
+ return bpmnRequestDetails;
+ }
+
+ private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) {
+ if (obj == null) {
+ throwExceptionWithWarn(delegateExecution,
+ "Unable to find the parameter: " + param + " in the execution context");
+ }
+ }
+
+ private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) {
+ logger.warn(exceptionMsg);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, exceptionMsg);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java
index a99ee7d..0b1c5b0 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java
@@ -20,6 +20,13 @@
package org.onap.so.bpmn.infrastructure.service.level;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -27,86 +34,79 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelPreparation;
import org.onap.so.client.exception.ExceptionBuilder;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.RESOURCE_TYPE;
-import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.WORKFLOW_TO_INVOKE;
+import org.onap.so.db.catalog.beans.Workflow;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {ServiceLevelPreparation.class, ExceptionBuilder.class})
-public class ServiceLevelPreparationTest {
+public class ServiceLevelPreparationTest extends BaseTaskTest {
private static final String TEST_PNF_SCOPE = "pnf";
private static final String TEST_PROCESS_KEY = "testProcessKey";
private static final String PROCESS_KEY_VALUE = "testProcessKeyValue";
- private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList("SERVICE_MODEL_INFO",
- "SERVICE_INSTANCE_NAME", "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME",
- "PRC_BLUEPRINT_VERSION", "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME",
- "PRC_CONTROLLER_ACTOR", "REQUEST_PAYLOAD");
- private Map<String, String> pnfHealthCheckTestParams = new HashMap<>();
+ private static final String BPMN_REQUEST = "bpmnRequest";
+ private static final String RESOURCE_TYPE = "resourceType";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ private static final String PNF_NAME = "pnfName";
+ private static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck";
+ private static final String PNF_HEALTH_CHECK_WORKFLOW = "PNFHealthCheck";
+ private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(TEST_PNF_SCOPE,
+ Arrays.asList(SERVICE_INSTANCE_ID, RESOURCE_TYPE, BPMN_REQUEST, PNF_NAME), "vnf", Collections.emptyList());
- @Autowired
- private ServiceLevelPreparation serviceLevelPrepare;
-
- @Autowired
- private ExceptionBuilder exceptionBuilder;
+ private List<Workflow> workflowList = new ArrayList<>();
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @InjectMocks
+ private ServiceLevelPreparation serviceLevelPrepare;
+
+ @InjectMocks
+ @Spy
+ private ExceptionBuilder exceptionBuilder;
+
private DelegateExecution execution = new DelegateExecutionFake();
private DelegateExecution invalidExecution = new DelegateExecutionFake();
@Before
public void setUpPnfUpgradeTest() {
- pnfHealthCheckTestParams.put("TEST_SERVICE_MODEL_INFO", "d4c6855e-3be2-5dtu-9390-c999a38829bc");
- pnfHealthCheckTestParams.put("TEST_SERVICE_INSTANCE_NAME", "test_service_id");
- pnfHealthCheckTestParams.put("TEST_PNF_CORRELATION_ID", "pnfCorrelationId");
- pnfHealthCheckTestParams.put("TEST_MODEL_UUID", "6bc0b04d-1873-4721-b53d-6615225b2a28");
- pnfHealthCheckTestParams.put("TEST_PNF_UUID", "c93g70d9-8de3-57f1-7de1-f5690ac2b005");
- pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_NAME", "serviceUpgrade");
- pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_VERSION", "1.0.2");
- pnfHealthCheckTestParams.put("TEST_PRC_CUSTOMIZATION_UUID", "PRC_customizationUuid");
- pnfHealthCheckTestParams.put("TEST_RESOURCE_CUSTOMIZATION_UUID_PARAM", "9acb3a83-8a52-412c-9a45-901764938144");
- pnfHealthCheckTestParams.put("TEST_PRC_INSTANCE_NAME", "Demo_pnf");
- pnfHealthCheckTestParams.put("TEST_PRC_CONTROLLER_ACTOR", "cds");
- pnfHealthCheckTestParams.put("TEST_REQUEST_PAYLOAD", "test_payload");
-
- for (String param : PNF_HEALTH_CHECK_PARAMS) {
- execution.setVariable(param, pnfHealthCheckTestParams.get("TEST_" + param));
- }
execution.setVariable(RESOURCE_TYPE, TEST_PNF_SCOPE);
execution.setVariable(TEST_PROCESS_KEY, PROCESS_KEY_VALUE);
+ execution.setVariable(BPMN_REQUEST, "bpmnRequestValue");
+ execution.setVariable(SERVICE_INSTANCE_ID, "serviceInstanceIdValue");
+ execution.setVariable(PNF_NAME, "PnfDemo");
invalidExecution.setVariables(execution.getVariables());
+
+ Workflow pnfWorkflow = new Workflow();
+ pnfWorkflow.setName(PNF_HEALTH_CHECK_WORKFLOW);
+ pnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION);
+ pnfWorkflow.setResourceTarget(TEST_PNF_SCOPE);
+ workflowList.add(pnfWorkflow);
+
+ when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList);
}
@Test
public void executePnfUpgradeSuccessTest() throws Exception {
serviceLevelPrepare.execute(execution);
// Expect the pnf health check workflow to be set in to execution if validation is successful
- assertThat(String.valueOf(execution.getVariable(WORKFLOW_TO_INVOKE))).isEqualTo("GenericPnfHealthCheck");
+ assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE)))
+ .isEqualTo("PNFHealthCheck");
}
@Test
public void validateFailureParamsForPnfTest() throws Exception {
- invalidExecution.removeVariable("PNF_UUID");
- invalidExecution.setVariable("PRC_BLUEPRINT_NAME", null);
+ invalidExecution.removeVariable(BPMN_REQUEST);
// BPMN exception is thrown in case of validation failure or invalid execution
thrown.expect(BpmnError.class);
- serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, PNF_HEALTH_CHECK_PARAMS);
+ serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE,
+ HEALTH_CHECK_PARAMS_MAP.get(TEST_PNF_SCOPE));
}
@Test
@@ -125,6 +125,32 @@
}
+ @Test
+ public void validateDefaultWorkflowIsSetWithoutDBData() throws Exception {
+ // Mock empty workflow list in db response
+ when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(new ArrayList<Workflow>());
+ serviceLevelPrepare.execute(execution);
+ // Expect default workflow gets assigned when workflow name not found in db.
+ assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE)))
+ .isEqualTo(ServiceLevelConstants.DEFAULT_HEALTH_CHECK_WORKFLOWS.get(TEST_PNF_SCOPE));
+ }
+
+ @Test
+ public void validateWorkflowSetFromDb() throws Exception {
+ Workflow vnfWorkflow = new Workflow();
+ vnfWorkflow.setName("VNFHealthCheck");
+ vnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION);
+ vnfWorkflow.setResourceTarget("vnf");
+ workflowList.add(vnfWorkflow);
+ // Mock db response with multiple worklfows mapped with same operation name
+ when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList);
+ serviceLevelPrepare.execute(execution);
+
+ // Expect right workflow gets assigned from db based on the controller scope.
+ assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE)))
+ .isEqualTo(PNF_HEALTH_CHECK_WORKFLOW);
+ }
+
}
diff --git a/common/pom.xml b/common/pom.xml
index 0855448..ff13da4 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -271,6 +271,15 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java
new file mode 100644
index 0000000..64f1df2
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AdditionalProperties.java
@@ -0,0 +1,23 @@
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
+public class AdditionalProperties implements Serializable {
+
+ private static final long serialVersionUID = -4020397418955518175L;
+
+ private SliceProfile sliceProfile;
+
+ private List<EndPoint> endPoints;
+
+ private NsiInfo nsiInfo;
+
+ private String scriptName;
+
+ private ModifyAction modifyAction;
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java
index 484f5b4..156f999 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java
@@ -25,12 +25,11 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AllocateAnNssi {
+ @Deprecated
public final static String URL = "/api/rest/provMns/v1/an/NSS" + "/SliceProfiles";
private String nsstId;
- private String flavorId;
-
private String nssiId;
private String nssiName;
@@ -51,14 +50,6 @@
this.nsstId = nsstId;
}
- public String getFlavorId() {
- return flavorId;
- }
-
- public void setFlavorId(String flavorId) {
- this.flavorId = flavorId;
- }
-
public String getNssiId() {
return nssiId;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java
index d036733..1d8b15e 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java
@@ -27,6 +27,7 @@
public class AllocateCnNssi implements Serializable {
public final static String URL = "/api/rest/provMns/v1/NSS/SliceProfiles";
+ private static final long serialVersionUID = 4909074863148869163L;
private String nsstId;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateNssi.java
new file mode 100644
index 0000000..1dc6d0f
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateNssi.java
@@ -0,0 +1,4 @@
+package org.onap.so.beans.nsmf;
+
+public class AllocateNssi {
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
index b66fb13..f85cb0c 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateTnNssi.java
@@ -20,90 +20,17 @@
package org.onap.so.beans.nsmf;
-import com.fasterxml.jackson.annotation.JsonInclude;
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class AllocateTnNssi {
+import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
- public final static String URL = "/api/rest/provMns/v1/tn/NSS" + "/SliceProfiles";
+@Data
+public class AllocateTnNssi implements Serializable {
- private String nsstId;
+ private static final long serialVersionUID = -7069801712339914746L;
- private String flavorId;
+ private List<NetworkSliceInfo> networkSliceInfos;
- private String nssiId;
-
- private String nssiName;
-
- private TnSliceProfile sliceProfile;
-
- private String scriptName;
-
- private Object extension;
-
- private NsiInfo nsiInfo;
-
- public String getNsstId() {
- return nsstId;
- }
-
- public void setNsstId(String nsstId) {
- this.nsstId = nsstId;
- }
-
- public String getFlavorId() {
- return flavorId;
- }
-
- public void setFlavorId(String flavorId) {
- this.flavorId = flavorId;
- }
-
- public String getNssiId() {
- return nssiId;
- }
-
- public void setNssiId(String nssiId) {
- this.nssiId = nssiId;
- }
-
- public String getNssiName() {
- return nssiName;
- }
-
- public void setNssiName(String nssiName) {
- this.nssiName = nssiName;
- }
-
- public TnSliceProfile getSliceProfile() {
- return sliceProfile;
- }
-
- public void setSliceProfile(TnSliceProfile sliceProfile) {
- this.sliceProfile = sliceProfile;
- }
-
- public String getScriptName() {
- return scriptName;
- }
-
- public void setScriptName(String scriptName) {
- this.scriptName = scriptName;
- }
-
- public Object getExtension() {
- return extension;
- }
-
- public void setExtension(Object extension) {
- this.extension = extension;
- }
-
- public NsiInfo getNsiInfo() {
- return nsiInfo;
- }
-
- public void setNsiInfo(NsiInfo nsiInfo) {
- this.nsiInfo = nsiInfo;
- }
+ private List<TransportSliceNetwork> transportSliceNetworks;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
index 3d60949..653f9ac 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
@@ -22,40 +22,31 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
public class AnSliceProfile {
- @JsonProperty("5QI")
- private String qi;
+ private List<String> sNSSAIList;
+
+ private String sliceProfileId;
private List<String> coverageAreaTAList;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private int latency;
- public String getQi() {
- return qi;
- }
+ private List<String> pLMNIdList;
- public void setQi(String qi) {
- this.qi = qi;
- }
+ private PerfReq perfReq;
- public List<String> getCoverageAreaTAList() {
- return coverageAreaTAList;
- }
+ @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ private int maxNumberofUEs;
- public void setCoverageAreaTAList(List<String> coverageAreaTAList) {
- this.coverageAreaTAList = coverageAreaTAList;
- }
+ private UeMobilityLevel uEMobilityLevel;
- public int getLatency() {
- return latency;
- }
+ private ResourceSharingLevel resourceSharingLevel;
- public void setLatency(int latency) {
- this.latency = latency;
- }
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java
new file mode 100644
index 0000000..ca0c684
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ConnectionLink.java
@@ -0,0 +1,33 @@
+package org.onap.so.beans.nsmf;
+
+
+import java.io.Serializable;
+
+
+public class ConnectionLink implements Serializable {
+ private static final long serialVersionUID = -1834584960407180427L;
+
+ private String transportEndpointA;
+
+ private String transportEndpointB;
+
+ public static long getSerialVersionUID() {
+ return serialVersionUID;
+ }
+
+ public String getTransportEndpointA() {
+ return transportEndpointA;
+ }
+
+ public void setTransportEndpointA(String transportEndpointA) {
+ this.transportEndpointA = transportEndpointA;
+ }
+
+ public String getTransportEndpointB() {
+ return transportEndpointB;
+ }
+
+ public void setTransportEndpointB(String transportEndpointB) {
+ this.transportEndpointB = transportEndpointB;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java
index 648fd49..1ee83c7 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/DeAllocateNssi.java
@@ -26,6 +26,7 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeAllocateNssi {
+ @Deprecated
public final static String URL = "/api/rest/provMns/v1/NSS" + "/SliceProfiles/%s";
private String nsiId;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java
new file mode 100644
index 0000000..a55672f
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java
@@ -0,0 +1,17 @@
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
+public class EndPoint implements Serializable {
+
+ private static final long serialVersionUID = 2479795890807020491L;
+
+ private String nodeId;
+
+ private Map<String, Object> additionalInfo;
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java
index d720399..f8ff5be 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/EsrInfo.java
@@ -26,6 +26,7 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EsrInfo implements Serializable {
+ private static final long serialVersionUID = -7696600990607396263L;
private String vendor;
private NetworkType networkType;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java b/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java
new file mode 100644
index 0000000..8206b52
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ModifyAction.java
@@ -0,0 +1,5 @@
+package org.onap.so.beans.nsmf;
+
+public enum ModifyAction {
+ allocate, deallocate
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java
new file mode 100644
index 0000000..67701a1
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NetworkSliceInfo.java
@@ -0,0 +1,16 @@
+package org.onap.so.beans.nsmf;
+
+
+import lombok.Data;
+import java.io.Serializable;
+
+@Data
+public class NetworkSliceInfo implements Serializable {
+ private static final long serialVersionUID = 4401921718259398587L;
+
+ private String snssai;
+
+ private String customer;
+
+ private String serviceType;
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java
index 0ff554d..d1679c6 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NsiInfo.java
@@ -37,11 +37,11 @@
this.nsiName = nsiName;
}
- public void setNsiId(String nsiId) {
- this.nsiId = nsiId;
- }
-
public String getNsiId() {
return nsiId;
}
+
+ public void setNsiId(String nsiId) {
+ this.nsiId = nsiId;
+ }
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
index f72a74a..9a25d6f 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiAllocateRequest.java
@@ -21,10 +21,15 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
@JsonInclude(JsonInclude.Include.NON_NULL)
-public class NssiAllocateRequest {
+public class NssiAllocateRequest implements Serializable {
+ private static final long serialVersionUID = -454145891489457960L;
+
+ @NotNull
private EsrInfo esrInfo;
private AllocateCnNssi allocateCnNssi;
@@ -33,6 +38,8 @@
private AllocateAnNssi allocateAnNssi;
+ private ServiceInfo serviceInfo;
+
public EsrInfo getEsrInfo() {
return esrInfo;
}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java
new file mode 100644
index 0000000..e421df4
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfAdapterNBIRequest.java
@@ -0,0 +1,32 @@
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import java.io.Serializable;
+
+
+@Data
+public class NssmfAdapterNBIRequest implements Serializable {
+
+ private static final long serialVersionUID = -454145891489457960L;
+
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private EsrInfo esrInfo;
+
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ private ServiceInfo serviceInfo;
+
+ private AllocateCnNssi allocateCnNssi;
+
+ private AllocateTnNssi allocateTnNssi;
+
+ private AllocateAnNssi allocateAnNssi;
+
+ private ActDeActNssi actDeActNssi;
+
+ private DeAllocateNssi deAllocateNssi;
+
+ private String subnetCapabilityQuery;
+
+ private String responseId;
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java
new file mode 100644
index 0000000..5a13933
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java
@@ -0,0 +1,54 @@
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import java.io.Serializable;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
+public class NssmfRequest implements Serializable {
+
+ private static final long serialVersionUID = 3313218757241310655L;
+
+ private String name;
+
+ private String modelInvariantUuid;
+
+ private String modelUuid;
+
+ private String globalSubscriberId;
+
+ private String serviceInstanceId;
+
+ private String subscriptionServiceType;
+
+ private NetworkType networkType;
+
+ private Object additionalProperties;
+
+ public NssmfRequest() {}
+
+ public NssmfRequest(ServiceInfo serviceInfo, NetworkType networkType, Object additionalProperties) {
+ this.modelInvariantUuid = serviceInfo.getServiceInvariantUuid();
+ this.modelUuid = serviceInfo.getServiceUuid();
+ this.globalSubscriberId = serviceInfo.getGlobalSubscriberId();
+ this.subscriptionServiceType = serviceInfo.getSubscriptionServiceType();
+ this.networkType = networkType;
+ this.additionalProperties = additionalProperties;
+ this.serviceInstanceId = serviceInfo.getNssiId();
+ this.name = serviceInfo.getNssiName();
+ }
+
+}
+
+
+/**
+ * { "name": "eMBB-001", "modelInvariantUuid": "NSST-C-001-HDBNJ-NSSMF-01-A-ZX", "modelUuid":
+ * "NSST-C-001-HDBNJ-NSSMF-01-A-ZX-UUID", "globalSubscriberId": "5GCustomer", "subscriptionServiceType": "5G",
+ * "networkType": "AN/CN/TN", "additionalProperties": { "sliceProfile": { "snssaiList": [ "001-100001" ],
+ * "sliceProfileId": "ab9af40f13f721b5f13539d87484098", "plmnIdList": [ "460-00", "460-01" ], "perfReq": {
+ * "perfReqEmbbList ": [ { "activityFactor": 50 } ] }, "maxNumberofUEs": 200, "coverageAreaTAList": [ "1", "2", "3", "4"
+ * ], "latency": 2, "resourceSharingLevel": "non-shared" }, "endPoints": [ { "nodeId": "", "additionalInfo": { "xxx":
+ * "xxx" } }, { "nodeId": "", "additionalInfo": { "xxx": "xxx" } } ], "nsiInfo": { "nsiId":
+ * "NSI-M-001-HDBNJ-NSMF-01-A-ZX", "nsiName": "eMBB-001" }, "scriptName": "AN1" } }
+ */
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java
new file mode 100644
index 0000000..f87c032
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceInfo.java
@@ -0,0 +1,31 @@
+package org.onap.so.beans.nsmf;
+
+import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class ServiceInfo implements Serializable {
+
+ private static final long serialVersionUID = 7895110339097615695L;
+
+ private String serviceInvariantUuid;
+
+ private String serviceUuid;
+
+ private String globalSubscriberId;
+
+ private String subscriptionServiceType;
+
+ private String serviceType;
+
+ private String nsiId;
+
+ private String nssiId;
+
+ private String sST;
+
+ private String nssiName;
+
+ private String pLMNIdList;
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java
index 6c5d9c6..cc6c9bb 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/ServiceProfile.java
@@ -21,7 +21,11 @@
package org.onap.so.beans.nsmf;
import java.io.Serializable;
+import java.util.HashMap;
import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java
new file mode 100644
index 0000000..6207705
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfile.java
@@ -0,0 +1,30 @@
+package org.onap.so.beans.nsmf;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
+public class SliceProfile implements Serializable {
+
+ private static final long serialVersionUID = 7924389625656716814L;
+
+ private List<String> snssaiList;
+
+ private String sliceProfileId;
+
+ private List<String> plmnIdList;
+
+ private PerfReq perfReq;
+
+ private Integer maxNumberofUEs;
+
+ private List<String> coverageAreaTAList;
+
+ private Integer latency;
+
+ private String resourceSharingLevel;
+
+}
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java
new file mode 100644
index 0000000..bfbbbd3
--- /dev/null
+++ b/common/src/main/java/org/onap/so/beans/nsmf/TransportSliceNetwork.java
@@ -0,0 +1,12 @@
+package org.onap.so.beans.nsmf;
+
+import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class TransportSliceNetwork implements Serializable {
+ private static final long serialVersionUID = 809947462399806990L;
+
+ private List<ConnectionLink> connectionLinks;
+}
diff --git a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java
index 9fdcb8e..6097f7e 100644
--- a/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java
+++ b/common/src/main/java/org/onap/so/client/cds/CDSProcessingHandler.java
@@ -46,7 +46,7 @@
ActionIdentifiers header = request.getActionIdentifiers();
log.info("Processing blueprint({}:{}) for action({})", header.getBlueprintVersion(), header.getBlueprintName(),
- header.getBlueprintVersion());
+ header.getActionName());
final CountDownLatch finishLatch = new CountDownLatch(1);
diff --git a/docs/api/swagger/swagger.html b/docs/api/swagger/swagger.html
index 5d7c963..514c2bd 100644
--- a/docs/api/swagger/swagger.html
+++ b/docs/api/swagger/swagger.html
@@ -843,11 +843,191 @@
},
"description" : "This describes the subnet capabilities that can be queried"
};
+ defs["RetrievingWorkflowResponse"] = {
+ "type" : "object",
+ "properties" : {
+ "workflowSpecificationList" : {
+ "type" : "array",
+ "description" : "List of Workflow specification data",
+ "items" : {
+ "$ref" : "#/definitions/WorkflowSpecification"
+ }
+ }
+ },
+ "description" : "Response body of fetching workflows using resource target"
+};
+ defs["ServiceLevelWorkflowExecution"] = {
+ "type" : "object",
+ "properties" : {
+ "requestInfo" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution_requestInfo"
+ },
+ "modelInfo" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution_modelInfo"
+ },
+ "requestParameters" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution_requestParameters"
+ },
+ "subscriberInfo" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution_subscriberInfo"
+ },
+ "project" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution_project"
+ },
+ "owningEntity" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution_owningEntity"
+ }
+ },
+ "description" : "This describes the request body of service level custom workflow execution"
+};
+ defs["ServiceLevelWorkflowExecution_modelInfo"] = {
+ "type" : "object",
+ "properties" : {
+ "modelType" : {
+ "type" : "string",
+ "description" : "Type of the model to be executed"
+ },
+ "modelInvariantUuid" : {
+ "type" : "string",
+ "description" : "Model invariant id corresponding to the service"
+ },
+ "modelUuid" : {
+ "type" : "string",
+ "description" : "Model uuid corresponding to the service"
+ },
+ "modelVersionId" : {
+ "type" : "string",
+ "description" : "Model version of the service instance"
+ },
+ "modelName" : {
+ "type" : "string",
+ "description" : "Name of the service"
+ },
+ "modelVersion" : {
+ "type" : "string",
+ "description" : "Version of the service instance"
+ }
+ },
+ "description" : "Parameters related to the service model"
+};
+ defs["ServiceLevelWorkflowExecution_owningEntity"] = {
+ "type" : "object",
+ "properties" : {
+ "owningEntityId" : {
+ "type" : "string",
+ "description" : "Id of the owning Entity"
+ },
+ "owningEntityName" : {
+ "type" : "string",
+ "description" : "Name of the owning Entity"
+ }
+ },
+ "description" : "Object describes the entity details"
+};
+ defs["ServiceLevelWorkflowExecution_project"] = {
+ "type" : "object",
+ "properties" : {
+ "projectName" : {
+ "type" : "string",
+ "description" : "Name of the target project"
+ }
+ },
+ "description" : "Information about the target project name"
+};
+ defs["ServiceLevelWorkflowExecution_requestInfo"] = {
+ "type" : "object",
+ "properties" : {
+ "source" : {
+ "type" : "string",
+ "description" : "Name of the sender"
+ },
+ "suppressRollback" : {
+ "type" : "boolean",
+ "description" : "Enable/disable rollback suppression"
+ },
+ "requestorId" : {
+ "type" : "string",
+ "description" : "Id of the sender"
+ }
+ },
+ "description" : "Request object contains source information"
+};
+ defs["ServiceLevelWorkflowExecution_requestParameters"] = {
+ "type" : "object",
+ "properties" : {
+ "subscriptionServiceType" : {
+ "type" : "string",
+ "description" : "Type of service subscription"
+ }
+ },
+ "description" : "User parameter object"
+};
+ defs["ServiceLevelWorkflowExecution_subscriberInfo"] = {
+ "type" : "object",
+ "properties" : {
+ "globalSubscriberId" : {
+ "type" : "string",
+ "description" : "Id of the subscriber sending the request"
+ }
+ },
+ "description" : "Subscriber id information"
+};
defs["SubnetTypes"] = {
"type" : "string",
"description" : "This describes allowed subnet types",
"enum" : [ "AN", "AN_NF", "CN", "TN_FH", "TN_MH", "TN_BH" ]
};
+ defs["WorkflowSpecification"] = {
+ "type" : "object",
+ "properties" : {
+ "artifactInfo" : {
+ "$ref" : "#/definitions/WorkflowSpecification_artifactInfo"
+ }
+ },
+ "description" : "This describes workflow specification object"
+};
+ defs["WorkflowSpecification_artifactInfo"] = {
+ "type" : "object",
+ "properties" : {
+ "artifactType" : {
+ "type" : "string",
+ "description" : "Type of the artifact to be queried"
+ },
+ "artifactUuid" : {
+ "type" : "string",
+ "description" : "UUID of the artifact"
+ },
+ "artifactName" : {
+ "type" : "string",
+ "description" : "Name of the artifact"
+ },
+ "artifactVersion" : {
+ "type" : "string",
+ "description" : "Artifact's Version"
+ },
+ "artifactDescription" : {
+ "type" : "string",
+ "description" : ""
+ },
+ "workflowName" : {
+ "type" : "string",
+ "description" : "Name of the workflow fetched for the resource type"
+ },
+ "operationName" : {
+ "type" : "string",
+ "description" : "Mapped operation name of the corresponding workflow"
+ },
+ "workflowSource" : {
+ "type" : "string",
+ "description" : ""
+ },
+ "workflowResourceTarget" : {
+ "type" : "string",
+ "description" : "Type of Resource mapped against the workflow"
+ }
+ },
+ "description" : "Attributes related to artifact information "
+};
</script>
<div class="container-fluid">
@@ -930,6 +1110,10 @@
<li data-group="OnapsoinfracloudResourcesRequests" data-name="unlockOrchestrationRequestForReqId" class="">
<a href="#api-OnapsoinfracloudResourcesRequests-unlockOrchestrationRequestForReqId">unlockOrchestrationRequestForReqId</a>
</li>
+ <li class="nav-header" data-group="OnapsoinfrainstanceManagement"><a href="#api-OnapsoinfrainstanceManagement">API Methods - OnapsoinfrainstanceManagement</a></li>
+ <li data-group="OnapsoinfrainstanceManagement" data-name="executeServiceLevelCustomWorkflow" class="">
+ <a href="#api-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow">executeServiceLevelCustomWorkflow</a>
+ </li>
<li class="nav-header" data-group="OnapsoinframodelDistributions"><a href="#api-OnapsoinframodelDistributions">API Methods - OnapsoinframodelDistributions</a></li>
<li data-group="OnapsoinframodelDistributions" data-name="updateModelDistributionStatus" class="">
<a href="#api-OnapsoinframodelDistributions-updateModelDistributionStatus">updateModelDistributionStatus</a>
@@ -1067,6 +1251,10 @@
<li data-group="Onapsoinfratasks" data-name="queryFilters" class="">
<a href="#api-Onapsoinfratasks-queryFilters">queryFilters</a>
</li>
+ <li class="nav-header" data-group="OnapsoinfraworkflowSpecifications"><a href="#api-OnapsoinfraworkflowSpecifications">API Methods - OnapsoinfraworkflowSpecifications</a></li>
+ <li data-group="OnapsoinfraworkflowSpecifications" data-name="queryWorkflowSpecifications" class="">
+ <a href="#api-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications">queryWorkflowSpecifications</a>
+ </li>
</ul>
</nav>
</div>
@@ -1449,7 +1637,7 @@
<article id="api-E2eServiceInstances-compareModelwithTargetVersion-0" data-group="User" data-name="compareModelwithTargetVersion" data-version="0">
<div class="pull-left">
<h1>compareModelwithTargetVersion</h1>
- <p>Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId </p>
+ <p>Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId</p>
</div>
<div class="pull-right"></div>
<div class="clearfix"></div>
@@ -1536,7 +1724,7 @@
E2eServiceInstancesApi *apiInstance = [[E2eServiceInstancesApi alloc] init];
-// Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId
+// Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId
[apiInstance compareModelwithTargetVersionWith:serviceId
version:version
body:body
@@ -1596,7 +1784,7 @@
try
{
- // Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId
+ // Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId
apiInstance.compareModelwithTargetVersion(serviceId, version, body);
}
catch (Exception e)
@@ -1658,7 +1846,7 @@
body = body_example # String | (optional)
try:
- # Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId
+ # Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId
api_instance.compare_modelwith_target_version(serviceId, version, body=body)
except ApiException as e:
print("Exception when calling E2eServiceInstancesApi->compareModelwithTargetVersion: %s\n" % e)</code></pre>
@@ -7385,6 +7573,366 @@
</div>
<hr>
</section>
+ <section id="api-OnapsoinfrainstanceManagement">
+ <h1>OnapsoinfrainstanceManagement</h1>
+ <div id="api-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow">
+ <article id="api-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0" data-group="User" data-name="executeServiceLevelCustomWorkflow" data-version="0">
+ <div class="pull-left">
+ <h1>executeServiceLevelCustomWorkflow</h1>
+ <p>Executing service level custom workflow</p>
+ </div>
+ <div class="pull-right"></div>
+ <div class="clearfix"></div>
+ <p></p>
+ <p class="marked"></p>
+ <p></p>
+ <br />
+ <pre class="prettyprint language-html prettyprinted" data-type="post"><code><span class="pln">/onap/so/infra/instanceManagement/{version}/serviceInstances/{serviceInstanceId}/workflows/{workflow_UUID}</span></code></pre>
+ <p>
+ <h3>Usage and SDK Samples</h3>
+ </p>
+ <ul class="nav nav-tabs nav-tabs-examples">
+ <li class="active"><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-curl">Curl</a></li>
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-java">Java</a></li>
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-android">Android</a></li>
+ <!--<li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-groovy">Groovy</a></li>-->
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-objc">Obj-C</a></li>
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-javascript">JavaScript</a></li>
+ <!--<li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-angular">Angular</a></li>-->
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-csharp">C#</a></li>
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-php">PHP</a></li>
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-perl">Perl</a></li>
+ <li class=""><a href="#examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-python">Python</a></li>
+ </ul>
+
+ <div class="tab-content">
+ <div class="tab-pane active" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-curl">
+ <pre class="prettyprint"><code class="language-bsh">curl -X POST "http://localhost/onap/so/infra/instanceManagement/{version}/serviceInstances/{serviceInstanceId}/workflows/{workflow_UUID}"</code></pre>
+ </div>
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-java">
+ <pre class="prettyprint"><code class="language-java">import io.swagger.client.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+import io.swagger.client.api.OnapsoinfrainstanceManagementApi;
+
+import java.io.File;
+import java.util.*;
+
+public class OnapsoinfrainstanceManagementApiExample {
+
+ public static void main(String[] args) {
+
+ OnapsoinfrainstanceManagementApi apiInstance = new OnapsoinfrainstanceManagementApi();
+ String version = version_example; // String |
+ String serviceInstanceId = serviceInstanceId_example; // String |
+ String workflowUUID = workflowUUID_example; // String |
+ ServiceLevelWorkflowExecution body = ; // ServiceLevelWorkflowExecution |
+ try {
+ apiInstance.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, body);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling OnapsoinfrainstanceManagementApi#executeServiceLevelCustomWorkflow");
+ e.printStackTrace();
+ }
+ }
+}</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-android">
+ <pre class="prettyprint"><code class="language-java">import io.swagger.client.api.OnapsoinfrainstanceManagementApi;
+
+public class OnapsoinfrainstanceManagementApiExample {
+
+ public static void main(String[] args) {
+ OnapsoinfrainstanceManagementApi apiInstance = new OnapsoinfrainstanceManagementApi();
+ String version = version_example; // String |
+ String serviceInstanceId = serviceInstanceId_example; // String |
+ String workflowUUID = workflowUUID_example; // String |
+ ServiceLevelWorkflowExecution body = ; // ServiceLevelWorkflowExecution |
+ try {
+ apiInstance.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, body);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling OnapsoinfrainstanceManagementApi#executeServiceLevelCustomWorkflow");
+ e.printStackTrace();
+ }
+ }
+}</code></pre>
+ </div>
+ <!--
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-groovy">
+ <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
+ </div> -->
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-objc">
+ <pre class="prettyprint"><code class="language-cpp">String *version = version_example; //
+String *serviceInstanceId = serviceInstanceId_example; //
+String *workflowUUID = workflowUUID_example; //
+ServiceLevelWorkflowExecution *body = ; // (optional)
+
+OnapsoinfrainstanceManagementApi *apiInstance = [[OnapsoinfrainstanceManagementApi alloc] init];
+
+// Executing service level custom workflow
+[apiInstance executeServiceLevelCustomWorkflowWith:version
+ serviceInstanceId:serviceInstanceId
+ workflowUUID:workflowUUID
+ body:body
+ completionHandler: ^(NSError* error) {
+ if (error) {
+ NSLog(@"Error: %@", error);
+ }
+ }];
+</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-javascript">
+ <pre class="prettyprint"><code class="language-js">var SoGuilinApIs = require('so_guilin_ap_is');
+
+var api = new SoGuilinApIs.OnapsoinfrainstanceManagementApi()
+
+var version = version_example; // {String}
+
+var serviceInstanceId = serviceInstanceId_example; // {String}
+
+var workflowUUID = workflowUUID_example; // {String}
+
+var opts = {
+ 'body': // {ServiceLevelWorkflowExecution}
+};
+
+var callback = function(error, data, response) {
+ if (error) {
+ console.error(error);
+ } else {
+ console.log('API called successfully.');
+ }
+};
+api.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, opts, callback);
+</code></pre>
+ </div>
+
+ <!--<div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-angular">
+ <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
+ </div>-->
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-csharp">
+ <pre class="prettyprint"><code class="language-cs">using System;
+using System.Diagnostics;
+using IO.Swagger.Api;
+using IO.Swagger.Client;
+using IO.Swagger.Model;
+
+namespace Example
+{
+ public class executeServiceLevelCustomWorkflowExample
+ {
+ public void main()
+ {
+
+ var apiInstance = new OnapsoinfrainstanceManagementApi();
+ var version = version_example; // String |
+ var serviceInstanceId = serviceInstanceId_example; // String |
+ var workflowUUID = workflowUUID_example; // String |
+ var body = new ServiceLevelWorkflowExecution(); // ServiceLevelWorkflowExecution | (optional)
+
+ try
+ {
+ // Executing service level custom workflow
+ apiInstance.executeServiceLevelCustomWorkflow(version, serviceInstanceId, workflowUUID, body);
+ }
+ catch (Exception e)
+ {
+ Debug.Print("Exception when calling OnapsoinfrainstanceManagementApi.executeServiceLevelCustomWorkflow: " + e.Message );
+ }
+ }
+ }
+}
+</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-php">
+ <pre class="prettyprint"><code class="language-php"><?php
+require_once(__DIR__ . '/vendor/autoload.php');
+
+$api_instance = new Swagger\Client\Api\OnapsoinfrainstanceManagementApi();
+$version = version_example; // String |
+$serviceInstanceId = serviceInstanceId_example; // String |
+$workflowUUID = workflowUUID_example; // String |
+$body = ; // ServiceLevelWorkflowExecution |
+
+try {
+ $api_instance->executeServiceLevelCustomWorkflow($version, $serviceInstanceId, $workflowUUID, $body);
+} catch (Exception $e) {
+ echo 'Exception when calling OnapsoinfrainstanceManagementApi->executeServiceLevelCustomWorkflow: ', $e->getMessage(), PHP_EOL;
+}
+?></code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-perl">
+ <pre class="prettyprint"><code class="language-perl">use Data::Dumper;
+use WWW::SwaggerClient::Configuration;
+use WWW::SwaggerClient::OnapsoinfrainstanceManagementApi;
+
+my $api_instance = WWW::SwaggerClient::OnapsoinfrainstanceManagementApi->new();
+my $version = version_example; # String |
+my $serviceInstanceId = serviceInstanceId_example; # String |
+my $workflowUUID = workflowUUID_example; # String |
+my $body = WWW::SwaggerClient::Object::ServiceLevelWorkflowExecution->new(); # ServiceLevelWorkflowExecution |
+
+eval {
+ $api_instance->executeServiceLevelCustomWorkflow(version => $version, serviceInstanceId => $serviceInstanceId, workflowUUID => $workflowUUID, body => $body);
+};
+if ($@) {
+ warn "Exception when calling OnapsoinfrainstanceManagementApi->executeServiceLevelCustomWorkflow: $@\n";
+}</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfrainstanceManagement-executeServiceLevelCustomWorkflow-0-python">
+ <pre class="prettyprint"><code class="language-python">from __future__ import print_statement
+import time
+import swagger_client
+from swagger_client.rest import ApiException
+from pprint import pprint
+
+# create an instance of the API class
+api_instance = swagger_client.OnapsoinfrainstanceManagementApi()
+version = version_example # String |
+serviceInstanceId = serviceInstanceId_example # String |
+workflowUUID = workflowUUID_example # String |
+body = # ServiceLevelWorkflowExecution | (optional)
+
+try:
+ # Executing service level custom workflow
+ api_instance.execute_service_level_custom_workflow(version, serviceInstanceId, workflowUUID, body=body)
+except ApiException as e:
+ print("Exception when calling OnapsoinfrainstanceManagementApi->executeServiceLevelCustomWorkflow: %s\n" % e)</code></pre>
+ </div>
+ </div>
+
+ <h2>Parameters</h2>
+
+ <div class="methodsubtabletitle">Path parameters</div>
+ <table id="methodsubtable">
+ <tr>
+ <th width="150px">Name</th>
+ <th>Description</th>
+ </tr>
+ <tr><td style="width:150px;">version*</td>
+<td>
+
+
+ <div id="d2e199_executeServiceLevelCustomWorkflow_version">
+ <div class="json-schema-view">
+ <div class="primitive">
+ <span class="type">
+ String
+ </span>
+
+ </div>
+ <div class="inner required">
+ Required
+ </div>
+ </div>
+ </div>
+</td>
+</tr>
+
+ <tr><td style="width:150px;">serviceInstanceId*</td>
+<td>
+
+
+ <div id="d2e199_executeServiceLevelCustomWorkflow_serviceInstanceId">
+ <div class="json-schema-view">
+ <div class="primitive">
+ <span class="type">
+ String
+ </span>
+
+ </div>
+ <div class="inner required">
+ Required
+ </div>
+ </div>
+ </div>
+</td>
+</tr>
+
+ <tr><td style="width:150px;">workflow_UUID*</td>
+<td>
+
+
+ <div id="d2e199_executeServiceLevelCustomWorkflow_workflowUUID">
+ <div class="json-schema-view">
+ <div class="primitive">
+ <span class="type">
+ String
+ </span>
+
+ </div>
+ <div class="inner required">
+ Required
+ </div>
+ </div>
+ </div>
+</td>
+</tr>
+
+ </table>
+
+
+ <div class="methodsubtabletitle">Body parameters</div>
+ <table id="methodsubtable">
+ <tr>
+ <th width="150px">Name</th>
+ <th>Description</th>
+ </tr>
+ <tr><td style="width:150px;">body </td>
+<td>
+
+
+<script>
+$(document).ready(function() {
+ var schemaWrapper = {
+ "in" : "body",
+ "name" : "body",
+ "required" : false,
+ "schema" : {
+ "$ref" : "#/definitions/ServiceLevelWorkflowExecution"
+ }
+};
+ var schema = schemaWrapper.schema;
+ if (schema.$ref != null) {
+ schema = defsParser.$refs.get(schema.$ref);
+ } else {
+ schemaWrapper.definitions = Object.assign({}, defs);
+ $RefParser.dereference(schemaWrapper).catch(function(err) {
+ console.log(err);
+ });
+ }
+
+ var view = new JSONSchemaView(schema,2,{isBodyParam: true});
+ var result = $('#d2e199_executeServiceLevelCustomWorkflow_body');
+ result.empty();
+ result.append(view.render());
+});
+</script>
+<div id="d2e199_executeServiceLevelCustomWorkflow_body"></div>
+</td>
+</tr>
+
+ </table>
+
+
+
+ <h2>Responses</h2>
+ <h3> Status: default - successful operation </h3>
+
+ <ul class="nav nav-tabs nav-tabs-examples" >
+ </ul>
+
+ <div class="tab-content" style='margin-bottom: 10px;'>
+ </div>
+
+ </article>
+ </div>
+ <hr>
+ </section>
<section id="api-OnapsoinframodelDistributions">
<h1>OnapsoinframodelDistributions</h1>
<div id="api-OnapsoinframodelDistributions-updateModelDistributionStatus">
@@ -22297,6 +22845,333 @@
</div>
<hr>
</section>
+ <section id="api-OnapsoinfraworkflowSpecifications">
+ <h1>OnapsoinfraworkflowSpecifications</h1>
+ <div id="api-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications">
+ <article id="api-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0" data-group="User" data-name="queryWorkflowSpecifications" data-version="0">
+ <div class="pull-left">
+ <h1>queryWorkflowSpecifications</h1>
+ <p>Retrieve Workflow details based on the filter criteria</p>
+ </div>
+ <div class="pull-right"></div>
+ <div class="clearfix"></div>
+ <p></p>
+ <p class="marked"></p>
+ <p></p>
+ <br />
+ <pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/onap/so/infra/workflowSpecifications/{version}/workflows</span></code></pre>
+ <p>
+ <h3>Usage and SDK Samples</h3>
+ </p>
+ <ul class="nav nav-tabs nav-tabs-examples">
+ <li class="active"><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-curl">Curl</a></li>
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-java">Java</a></li>
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-android">Android</a></li>
+ <!--<li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-groovy">Groovy</a></li>-->
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-objc">Obj-C</a></li>
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-javascript">JavaScript</a></li>
+ <!--<li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-angular">Angular</a></li>-->
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-csharp">C#</a></li>
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-php">PHP</a></li>
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-perl">Perl</a></li>
+ <li class=""><a href="#examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-python">Python</a></li>
+ </ul>
+
+ <div class="tab-content">
+ <div class="tab-pane active" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-curl">
+ <pre class="prettyprint"><code class="language-bsh">curl -X GET "http://localhost/onap/so/infra/workflowSpecifications/{version}/workflows?resourceTarget="</code></pre>
+ </div>
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-java">
+ <pre class="prettyprint"><code class="language-java">import io.swagger.client.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+import io.swagger.client.api.OnapsoinfraworkflowSpecificationsApi;
+
+import java.io.File;
+import java.util.*;
+
+public class OnapsoinfraworkflowSpecificationsApiExample {
+
+ public static void main(String[] args) {
+
+ OnapsoinfraworkflowSpecificationsApi apiInstance = new OnapsoinfraworkflowSpecificationsApi();
+ String version = version_example; // String |
+ String resourceTarget = resourceTarget_example; // String |
+ try {
+ RetrievingWorkflowResponse result = apiInstance.queryWorkflowSpecifications(version, resourceTarget);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling OnapsoinfraworkflowSpecificationsApi#queryWorkflowSpecifications");
+ e.printStackTrace();
+ }
+ }
+}</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-android">
+ <pre class="prettyprint"><code class="language-java">import io.swagger.client.api.OnapsoinfraworkflowSpecificationsApi;
+
+public class OnapsoinfraworkflowSpecificationsApiExample {
+
+ public static void main(String[] args) {
+ OnapsoinfraworkflowSpecificationsApi apiInstance = new OnapsoinfraworkflowSpecificationsApi();
+ String version = version_example; // String |
+ String resourceTarget = resourceTarget_example; // String |
+ try {
+ RetrievingWorkflowResponse result = apiInstance.queryWorkflowSpecifications(version, resourceTarget);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling OnapsoinfraworkflowSpecificationsApi#queryWorkflowSpecifications");
+ e.printStackTrace();
+ }
+ }
+}</code></pre>
+ </div>
+ <!--
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-groovy">
+ <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
+ </div> -->
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-objc">
+ <pre class="prettyprint"><code class="language-cpp">String *version = version_example; //
+String *resourceTarget = resourceTarget_example; // (optional)
+
+OnapsoinfraworkflowSpecificationsApi *apiInstance = [[OnapsoinfraworkflowSpecificationsApi alloc] init];
+
+// Retrieve Workflow details based on the filter criteria
+[apiInstance queryWorkflowSpecificationsWith:version
+ resourceTarget:resourceTarget
+ completionHandler: ^(RetrievingWorkflowResponse output, NSError* error) {
+ if (output) {
+ NSLog(@"%@", output);
+ }
+ if (error) {
+ NSLog(@"Error: %@", error);
+ }
+ }];
+</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-javascript">
+ <pre class="prettyprint"><code class="language-js">var SoGuilinApIs = require('so_guilin_ap_is');
+
+var api = new SoGuilinApIs.OnapsoinfraworkflowSpecificationsApi()
+
+var version = version_example; // {String}
+
+var opts = {
+ 'resourceTarget': resourceTarget_example // {String}
+};
+
+var callback = function(error, data, response) {
+ if (error) {
+ console.error(error);
+ } else {
+ console.log('API called successfully. Returned data: ' + data);
+ }
+};
+api.queryWorkflowSpecifications(version, opts, callback);
+</code></pre>
+ </div>
+
+ <!--<div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-angular">
+ <pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
+ </div>-->
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-csharp">
+ <pre class="prettyprint"><code class="language-cs">using System;
+using System.Diagnostics;
+using IO.Swagger.Api;
+using IO.Swagger.Client;
+using IO.Swagger.Model;
+
+namespace Example
+{
+ public class queryWorkflowSpecificationsExample
+ {
+ public void main()
+ {
+
+ var apiInstance = new OnapsoinfraworkflowSpecificationsApi();
+ var version = version_example; // String |
+ var resourceTarget = resourceTarget_example; // String | (optional)
+
+ try
+ {
+ // Retrieve Workflow details based on the filter criteria
+ RetrievingWorkflowResponse result = apiInstance.queryWorkflowSpecifications(version, resourceTarget);
+ Debug.WriteLine(result);
+ }
+ catch (Exception e)
+ {
+ Debug.Print("Exception when calling OnapsoinfraworkflowSpecificationsApi.queryWorkflowSpecifications: " + e.Message );
+ }
+ }
+ }
+}
+</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-php">
+ <pre class="prettyprint"><code class="language-php"><?php
+require_once(__DIR__ . '/vendor/autoload.php');
+
+$api_instance = new Swagger\Client\Api\OnapsoinfraworkflowSpecificationsApi();
+$version = version_example; // String |
+$resourceTarget = resourceTarget_example; // String |
+
+try {
+ $result = $api_instance->queryWorkflowSpecifications($version, $resourceTarget);
+ print_r($result);
+} catch (Exception $e) {
+ echo 'Exception when calling OnapsoinfraworkflowSpecificationsApi->queryWorkflowSpecifications: ', $e->getMessage(), PHP_EOL;
+}
+?></code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-perl">
+ <pre class="prettyprint"><code class="language-perl">use Data::Dumper;
+use WWW::SwaggerClient::Configuration;
+use WWW::SwaggerClient::OnapsoinfraworkflowSpecificationsApi;
+
+my $api_instance = WWW::SwaggerClient::OnapsoinfraworkflowSpecificationsApi->new();
+my $version = version_example; # String |
+my $resourceTarget = resourceTarget_example; # String |
+
+eval {
+ my $result = $api_instance->queryWorkflowSpecifications(version => $version, resourceTarget => $resourceTarget);
+ print Dumper($result);
+};
+if ($@) {
+ warn "Exception when calling OnapsoinfraworkflowSpecificationsApi->queryWorkflowSpecifications: $@\n";
+}</code></pre>
+ </div>
+
+ <div class="tab-pane" id="examples-OnapsoinfraworkflowSpecifications-queryWorkflowSpecifications-0-python">
+ <pre class="prettyprint"><code class="language-python">from __future__ import print_statement
+import time
+import swagger_client
+from swagger_client.rest import ApiException
+from pprint import pprint
+
+# create an instance of the API class
+api_instance = swagger_client.OnapsoinfraworkflowSpecificationsApi()
+version = version_example # String |
+resourceTarget = resourceTarget_example # String | (optional)
+
+try:
+ # Retrieve Workflow details based on the filter criteria
+ api_response = api_instance.query_workflow_specifications(version, resourceTarget=resourceTarget)
+ pprint(api_response)
+except ApiException as e:
+ print("Exception when calling OnapsoinfraworkflowSpecificationsApi->queryWorkflowSpecifications: %s\n" % e)</code></pre>
+ </div>
+ </div>
+
+ <h2>Parameters</h2>
+
+ <div class="methodsubtabletitle">Path parameters</div>
+ <table id="methodsubtable">
+ <tr>
+ <th width="150px">Name</th>
+ <th>Description</th>
+ </tr>
+ <tr><td style="width:150px;">version*</td>
+<td>
+
+
+ <div id="d2e199_queryWorkflowSpecifications_version">
+ <div class="json-schema-view">
+ <div class="primitive">
+ <span class="type">
+ String
+ </span>
+
+ </div>
+ <div class="inner required">
+ Required
+ </div>
+ </div>
+ </div>
+</td>
+</tr>
+
+ </table>
+
+
+
+
+ <div class="methodsubtabletitle">Query parameters</div>
+ <table id="methodsubtable">
+ <tr>
+ <th width="150px">Name</th>
+ <th>Description</th>
+ </tr>
+ <tr><td style="width:150px;">resourceTarget</td>
+<td>
+
+
+ <div id="d2e199_queryWorkflowSpecifications_resourceTarget">
+ <div class="json-schema-view">
+ <div class="primitive">
+ <span class="type">
+ String
+ </span>
+
+ </div>
+ </div>
+ </div>
+</td>
+</tr>
+
+ </table>
+
+ <h2>Responses</h2>
+ <h3> Status: default - List of workflow specifications on successful operation </h3>
+
+ <ul class="nav nav-tabs nav-tabs-examples" >
+ <li class="active">
+ <a data-toggle="tab" href="#responses-queryWorkflowSpecifications-default-schema">Schema</a>
+ </li>
+
+ </ul>
+
+ <div class="tab-content" style='margin-bottom: 10px;'>
+ <div class="tab-pane active" id="responses-queryWorkflowSpecifications-default-schema">
+ <div id='responses-queryWorkflowSpecifications-default-schema-default' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
+ <script>
+ $(document).ready(function() {
+ var schemaWrapper = {
+ "description" : "List of workflow specifications on successful operation",
+ "schema" : {
+ "$ref" : "#/definitions/RetrievingWorkflowResponse"
+ }
+};
+ var schema = schemaWrapper.schema;
+ if (schema.$ref != null) {
+ schema = defsParser.$refs.get(schema.$ref);
+ } else {
+ schemaWrapper.definitions = defs;
+ $RefParser.dereference(schemaWrapper).catch(function(err) {
+ console.log(err);
+ });
+ }
+
+ //console.log(JSON.stringify(schema));
+ var view = new JSONSchemaView(schema, 3);
+ $('#responses-queryWorkflowSpecifications-default-schema-data').val(stringify(schema));
+ var result = $('#responses-queryWorkflowSpecifications-default-schema-default');
+ result.empty();
+ result.append(view.render());
+ });
+ </script>
+ </div>
+ <input id='responses-queryWorkflowSpecifications-default-schema-data' type='hidden' value=''></input>
+ </div>
+ </div>
+
+ </article>
+ </div>
+ <hr>
+ </section>
</div>
<div id="footer">
<div id="api-_footer">
diff --git a/docs/api/swagger/swagger.json b/docs/api/swagger/swagger.json
index bee195c..4ec404e 100644
--- a/docs/api/swagger/swagger.json
+++ b/docs/api/swagger/swagger.json
@@ -37,6 +37,12 @@
},
{
"name": "onapsoinframodelDistributions"
+ },
+ {
+ "name": "onapsoinfraworkflowSpecifications"
+ },
+ {
+ "name": "onapsoinfrainstanceManagement"
}
],
"schemes": [
@@ -2845,6 +2851,95 @@
}
}
}
+ },
+ "/onap/so/infra/workflowSpecifications/{version}/workflows": {
+ "get": {
+ "tags": [
+ "onapsoinfraworkflowSpecifications"
+ ],
+ "summary": "Retrieve Workflow details based on the filter criteria",
+ "description": "",
+ "operationId": "queryWorkflowSpecifications",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "resourceTarget",
+ "in": "query",
+ "required": false,
+ "type": "string"
+ },
+ {
+ "name": "version",
+ "in": "path",
+ "required": true,
+ "type": "string",
+ "pattern": "[vV][1]"
+ }
+ ],
+ "responses": {
+ "default": {
+ "description": "List of workflow specifications on successful operation",
+ "schema": {
+ "$ref": "#/definitions/RetrievingWorkflowResponse"
+ }
+ }
+ }
+ }
+ },
+ "/onap/so/infra/instanceManagement/{version}/serviceInstances/{serviceInstanceId}/workflows/{workflow_UUID}": {
+ "post": {
+ "tags": [
+ "onapsoinfrainstanceManagement"
+ ],
+ "summary": "Executing service level custom workflow",
+ "description": "",
+ "operationId": "executeServiceLevelCustomWorkflow",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "required": false,
+ "schema": {
+ "$ref": "#/definitions/ServiceLevelWorkflowExecution"
+ }
+ },
+ {
+ "name": "version",
+ "in": "path",
+ "required": true,
+ "type": "string",
+ "pattern": "[vV][1]"
+ },
+ {
+ "name": "serviceInstanceId",
+ "in": "path",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "name": "workflow_UUID",
+ "in": "path",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ }
+ }
}
},
"definitions": {
@@ -3001,6 +3096,166 @@
"type": "object"
}
}
+ },
+ "RetrievingWorkflowResponse": {
+ "description": "Response body of fetching workflows using resource target",
+ "type": "object",
+ "properties": {
+ "workflowSpecificationList":{
+ "description": "List of Workflow specification data",
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/WorkflowSpecification"
+ }
+ }
+ }
+ },
+ "WorkflowSpecification": {
+ "description": "This describes workflow specification object",
+ "type": "object",
+ "properties": {
+ "artifactInfo": {
+ "description": "Attributes related to artifact information ",
+ "type": "object",
+ "properties": {
+ "artifactType": {
+ "description": "Type of the artifact to be queried",
+ "type": "string"
+ },
+ "artifactUuid": {
+ "description": "UUID of the artifact",
+ "type": "string"
+ },
+ "artifactName": {
+ "description": "Name of the artifact",
+ "type": "string"
+ },
+ "artifactVersion": {
+ "description": "Artifact's Version",
+ "type": "string"
+ },
+ "artifactDescription": {
+ "description": "",
+ "type": "string"
+ },
+ "workflowName": {
+ "description": "Name of the workflow fetched for the resource type",
+ "type": "string"
+ },
+ "operationName": {
+ "description": "Mapped operation name of the corresponding workflow",
+ "type": "string"
+ },
+ "workflowSource": {
+ "description": "",
+ "type": "string"
+ },
+ "workflowResourceTarget": {
+ "description": "Type of Resource mapped against the workflow",
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "ServiceLevelWorkflowExecution": {
+ "description": "This describes the request body of service level custom workflow execution",
+ "type": "object",
+ "properties": {
+ "requestInfo": {
+ "description": "Request object contains source information",
+ "type": "object",
+ "properties": {
+ "source": {
+ "description": "Name of the sender",
+ "type": "string"
+ },
+ "suppressRollback": {
+ "description": "Enable/disable rollback suppression",
+ "type": "boolean"
+ },
+ "requestorId": {
+ "description": "Id of the sender",
+ "type": "string"
+ }
+ }
+ },
+ "modelInfo": {
+ "description": "Parameters related to the service model",
+ "type": "object",
+ "properties": {
+ "modelType": {
+ "description": "Type of the model to be executed",
+ "type": "string"
+ },
+ "modelInvariantUuid": {
+ "description": "Model invariant id corresponding to the service",
+ "type": "string"
+ },
+ "modelUuid": {
+ "description": "Model uuid corresponding to the service",
+ "type": "string"
+ },
+ "modelVersionId": {
+ "description": "Model version of the service instance",
+ "type": "string"
+ },
+ "modelName": {
+ "description": "Name of the service",
+ "type": "string"
+ },
+ "modelVersion": {
+ "description": "Version of the service instance",
+ "type": "string"
+ }
+ }
+ },
+ "requestParameters": {
+ "description": "User parameter object",
+ "type": "object",
+ "properties": {
+ "subscriptionServiceType": {
+ "description": "Type of service subscription",
+ "type": "string"
+ }
+ }
+ },
+ "subscriberInfo": {
+ "description": "Subscriber id information",
+ "type": "object",
+ "properties": {
+ "globalSubscriberId": {
+ "description": "Id of the subscriber sending the request",
+ "type": "string"
+ }
+ }
+ },
+ "project": {
+ "description": "Information about the target project name",
+ "type": "object",
+ "properties": {
+ "projectName":{
+ "description": "Name of the target project",
+ "type": "string"
+ }
+ }
+ },
+ "owningEntity": {
+ "description": "Object describes the entity details",
+ "type": "object",
+ "properties": {
+ "owningEntityId": {
+ "description": "Id of the owning Entity",
+ "type": "string"
+ },
+ "owningEntityName": {
+ "description": "Name of the owning Entity",
+ "type": "string"
+ }
+ }
+ }
+
+ }
}
}
}
\ No newline at end of file
diff --git a/docs/api/swagger/swagger.yaml b/docs/api/swagger/swagger.yaml
index f0f3a87..181a8df 100644
--- a/docs/api/swagger/swagger.yaml
+++ b/docs/api/swagger/swagger.yaml
@@ -14,6 +14,8 @@
- name: onapsoinfracloudResources
- name: onapsoinfracloudResourcesRequests
- name: onapsoinframodelDistributions
+ - name: onapsoinfraworkflowSpecifications
+ - name: onapsoinfrainstanceManagement
schemes:
- http
paths:
@@ -196,7 +198,7 @@
- e2eServiceInstances
summary: >-
Find added and deleted resources of target model for the
- e2eserviceInstance on a given serviceId
+ e2eserviceInstance on a given serviceId
description: ''
operationId: compareModelwithTargetVersion
consumes:
@@ -1881,6 +1883,65 @@
responses:
default:
description: successful operation
+ '/onap/so/infra/workflowSpecifications/{version}/workflows':
+ get:
+ tags:
+ - onapsoinfraworkflowSpecifications
+ summary: Retrieve Workflow details based on the filter criteria
+ description: ''
+ operationId: queryWorkflowSpecifications
+ consumes:
+ - application/json
+ produces:
+ - application/json
+ parameters:
+ - name: resourceTarget
+ in: query
+ required: false
+ type: string
+ - name: version
+ in: path
+ required: true
+ type: string
+ pattern: '[vV][1]'
+ responses:
+ default:
+ description: List of workflow specifications on successful operation
+ schema:
+ $ref: '#/definitions/RetrievingWorkflowResponse'
+ '/onap/so/infra/instanceManagement/{version}/serviceInstances/{serviceInstanceId}/workflows/{workflow_UUID}':
+ post:
+ tags:
+ - onapsoinfrainstanceManagement
+ summary: Executing service level custom workflow
+ description: ''
+ operationId: executeServiceLevelCustomWorkflow
+ consumes:
+ - application/json
+ produces:
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ required: false
+ schema:
+ $ref: '#/definitions/ServiceLevelWorkflowExecution'
+ - name: version
+ in: path
+ required: true
+ type: string
+ pattern: '[vV][1]'
+ - name: serviceInstanceId
+ in: path
+ required: true
+ type: string
+ - name: workflow_UUID
+ in: path
+ required: true
+ type: string
+ responses:
+ default:
+ description: successful operation
definitions:
Allocate3gppService:
description: This describes the request body for 3gpp service allocation
@@ -2000,3 +2061,117 @@
statusDescription:
description: Description on status in case of erroneous response
type: object
+ RetrievingWorkflowResponse:
+ description: Response body of fetching workflows using resource target
+ type: object
+ properties:
+ workflowSpecificationList:
+ description: List of Workflow specification data
+ type: array
+ items:
+ $ref: '#/definitions/WorkflowSpecification'
+ WorkflowSpecification:
+ description: This describes workflow specification object
+ type: object
+ properties:
+ artifactInfo:
+ description: 'Attributes related to artifact information '
+ type: object
+ properties:
+ artifactType:
+ description: Type of the artifact to be queried
+ type: string
+ artifactUuid:
+ description: UUID of the artifact
+ type: string
+ artifactName:
+ description: Name of the artifact
+ type: string
+ artifactVersion:
+ description: Artifact's Version
+ type: string
+ artifactDescription:
+ description: ''
+ type: string
+ workflowName:
+ description: Name of the workflow fetched for the resource type
+ type: string
+ operationName:
+ description: Mapped operation name of the corresponding workflow
+ type: string
+ workflowSource:
+ description: ''
+ type: string
+ workflowResourceTarget:
+ description: Type of Resource mapped against the workflow
+ type: string
+ ServiceLevelWorkflowExecution:
+ description: This describes the request body of service level custom workflow execution
+ type: object
+ properties:
+ requestInfo:
+ description: Request object contains source information
+ type: object
+ properties:
+ source:
+ description: Name of the sender
+ type: string
+ suppressRollback:
+ description: Enable/disable rollback suppression
+ type: boolean
+ requestorId:
+ description: Id of the sender
+ type: string
+ modelInfo:
+ description: Parameters related to the service model
+ type: object
+ properties:
+ modelType:
+ description: Type of the model to be executed
+ type: string
+ modelInvariantUuid:
+ description: Model invariant id corresponding to the service
+ type: string
+ modelUuid:
+ description: Model uuid corresponding to the service
+ type: string
+ modelVersionId:
+ description: Model version of the service instance
+ type: string
+ modelName:
+ description: Name of the service
+ type: string
+ modelVersion:
+ description: Version of the service instance
+ type: string
+ requestParameters:
+ description: User parameter object
+ type: object
+ properties:
+ subscriptionServiceType:
+ description: Type of service subscription
+ type: string
+ subscriberInfo:
+ description: Subscriber id information
+ type: object
+ properties:
+ globalSubscriberId:
+ description: Id of the subscriber sending the request
+ type: string
+ project:
+ description: Information about the target project name
+ type: object
+ properties:
+ projectName:
+ description: Name of the target project
+ type: string
+ owningEntity:
+ description: Object describes the entity details
+ type: object
+ properties:
+ owningEntityId:
+ description: Id of the owning Entity
+ type: string
+ owningEntityName:
+ description: Name of the owning Entity
+ type: string
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java
index ef6ca00..3b08761 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientI.java
@@ -26,6 +26,7 @@
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Pnf;
import org.onap.aai.domain.yang.Pserver;
+import org.onap.aai.domain.yang.ServiceInstance;
public interface AAIRestClientI {
@@ -40,4 +41,10 @@
void createPnf(String pnfId, Pnf pnf);
void updatePnf(String pnfId, Pnf pnf);
+
+ Optional<ServiceInstance> getServiceInstanceById(String serviceInstanceId, String serviceType,
+ String globalSubscriberId);
+
+ void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId,
+ ServiceInstance serviceInstance);
}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java
index 886891a..0aff965 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClientImpl.java
@@ -31,14 +31,18 @@
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Pnf;
import org.onap.aai.domain.yang.Pserver;
+import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aaiclient.client.aai.entities.CustomQuery;
import org.onap.aaiclient.client.aai.entities.Results;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.graphinventory.Format;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class AAIRestClientImpl implements AAIRestClientI {
+ private final Logger log = LoggerFactory.getLogger(getClass());
private static final String PSERVER_VNF_QUERY = "pservers-fromVnf";
@Override
@@ -97,4 +101,24 @@
public void updatePnf(String pnfId, Pnf pnf) {
new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfId), pnf);
}
+
+ @Override
+ public Optional<ServiceInstance> getServiceInstanceById(String globalSubscriberId, String serviceType,
+ String serviceInstanceId) {
+ Response response = new AAIResourcesClient().getFullResponse(AAIUriFactory
+ .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId));
+ return Optional.ofNullable(response.readEntity(ServiceInstance.class));
+ }
+
+ @Override
+ public void updateServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId,
+ ServiceInstance serviceInstance) {
+ try {
+ new AAIResourcesClient().update(AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, serviceType, serviceInstanceId), serviceInstance);
+ } catch (Throwable ex) {
+ log.error("Exception happened while updating ServiceInstance, Exception: {}", ex.getLocalizedMessage());
+ throw new RuntimeException(ex);
+ }
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 8d342b6..ef90dd6 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -20,6 +20,7 @@
package org.onap.so.db.catalog.client;
+import com.google.common.base.Strings;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
@@ -83,7 +84,6 @@
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
-import com.google.common.base.Strings;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
@@ -162,6 +162,7 @@
protected static final String SOURCE = "source";
protected static final String RESOURCE_TARGET = "resourceTarget";
protected static final String FLAG = "flag";
+ protected static final String OPERATION_NAME = "operationName";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -215,6 +216,7 @@
"/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
private String findWorkflowByResourceTarget = "/findByResourceTarget";
private String findProcessingFlagsByFlag = "/findByFlag";
+ private String findWorkflowByOperationName = "/findByOperationName";
private String serviceURI;
private String vfModuleURI;
@@ -365,6 +367,7 @@
+ findBBNameSelectionReferenceByControllerActorAndScopeAndAction;
findProcessingFlagsByFlag = endpoint + PROCESSING_FLAGS + SEARCH + findProcessingFlagsByFlag;
+ findWorkflowByOperationName = endpoint + WORKFLOW + SEARCH + findWorkflowByOperationName;
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
@@ -1106,6 +1109,11 @@
.queryParam(RESOURCE_TARGET, resourceTarget).build().toString()));
}
+ public List<Workflow> findWorkflowByOperationName(String operationName) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByOperationName)
+ .queryParam(OPERATION_NAME, operationName).build().toString()));
+ }
+
public ProcessingFlags findProcessingFlagsByFlag(String flag) {
return this.getSingleResource(processingFlagsClient,
getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).build().toString()));
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
index 93ec54a..74843e5 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
@@ -35,6 +35,8 @@
List<Workflow> findByResourceTarget(String resourceTarget);
+ List<Workflow> findByOperationName(String operationName);
+
/**
* Used to fetch the @{link Workflow} by the Model UUID.
*
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index 79e3cbc..6a5daa6 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -204,4 +204,15 @@
.queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build()));
}
+ @Test
+ public final void testFindWorkFlowByOperationName() {
+ final String operationName = "PNFSoftwareUpgrade";
+ doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+ catalogDbClient.findWorkflowByOperationName(operationName);
+
+ // verify
+ verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByOperationName")
+ .queryParam(CatalogDbClient.OPERATION_NAME, operationName).build()));
+ }
+
}
diff --git a/pom.xml b/pom.xml
index 90e347b..2fed5a8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
<sonar.cpd.exclusions>**/*</sonar.cpd.exclusions>
<jacoco.version>0.8.5</jacoco.version>
<org.apache.maven.user-settings />
- <openstack.version>1.6.1</openstack.version>
+ <openstack.version>1.7.1</openstack.version>
<maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
<originalClassifier>original</originalClassifier>
<docker.skip>true</docker.skip>
diff --git a/releases/1.7.1.yaml b/releases/1.7.1.yaml
new file mode 100644
index 0000000..db50567
--- /dev/null
+++ b/releases/1.7.1.yaml
@@ -0,0 +1,31 @@
+---
+distribution_type: 'container'
+container_release_tag: '1.7.1'
+project: 'so'
+log_dir: 'so-maven-docker-stage-master/427/'
+ref: '16faef60a02ca16b6f0c88082c2244241d57c15c'
+containers:
+ - name: 'so/vnfm-adapter'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/catalog-db-adapter'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/request-db-adapter'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/openstack-adapter'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/sdnc-adapter'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/vfc-adapter'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/sdc-controller'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/bpmn-infra'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/so-monitoring'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/api-handler-infra'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/so-appc-orchestrator'
+ version: '1.7.1-20200817T0419'
+ - name: 'so/nssmf-adapter'
+ version: '1.7.1-20200817T0419'
\ No newline at end of file
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json
index 8257e6b..8a7eb9d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-api/src/main/resources/SOL005-NSLifecycleManagement-API.json
@@ -75,7 +75,8 @@
},
"retirementDate":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
}
}
}
@@ -9667,7 +9668,8 @@
},
"startTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"nsInstantiationLevelId":{
"description":"An identifier that is unique within a NS descriptor. Representation: string of variable length.\n",
@@ -10745,7 +10747,8 @@
},
"scaleTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
}
}
},
@@ -13113,7 +13116,8 @@
},
"updateTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
}
}
},
@@ -15175,7 +15179,8 @@
},
"statusEnteredTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"nsInstanceId":{
"description":"An identifier with the intention of being globally unique.\n",
@@ -15194,7 +15199,8 @@
},
"startTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"isAutomaticInvocation":{
"description":"Set to true if this NS LCM operation occurrence has been automatically triggered by the NFVO. This occurs in the case of auto-scaling, auto-healing and when a nested NS is modified as a result of an operation on its composite NS. Set to false otherwise.\n",
@@ -15202,14 +15208,7 @@
},
"operationParams":{
"description":"Input parameters of the LCM operation. This attribute shall be formatted according to the request data type of the related LCM operation. The following mapping between lcmOperationType and the data type of this attribute shall apply: - INSTANTIATE: InstantiateNsRequest - SCALE: ScaleNsRequest - UPDATE: UpdateNsRequest - HEAL: HealNsRequest - TERMINATE: TerminateNsRequest This attribute shall be present if this data type is returned in a response to reading an individual resource, and may be present according to the chosen attribute selector parameter if this data type is returned in a response to a query of a container resource.\n",
- "type":"string",
- "enum":[
- "INSTANTIATE",
- "SCALE",
- "UPDATE",
- "HEAL",
- "TERMINATE"
- ]
+ "type":"object"
},
"isCancelPending":{
"description":"If the LCM operation occurrence is in \"PROCESSING\" or \"ROLLING_BACK\" state and the operation is being cancelled, this attribute shall be set to true. Otherwise, it shall be set to false.\n",
@@ -16396,7 +16395,8 @@
},
"statusEnteredTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"nsInstanceId":{
"description":"An identifier with the intention of being globally unique.\n",
@@ -16415,7 +16415,8 @@
},
"startTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"isAutomaticInvocation":{
"description":"Set to true if this NS LCM operation occurrence has been automatically triggered by the NFVO. This occurs in the case of auto-scaling, auto-healing and when a nested NS is modified as a result of an operation on its composite NS. Set to false otherwise.\n",
@@ -16423,14 +16424,7 @@
},
"operationParams":{
"description":"Input parameters of the LCM operation. This attribute shall be formatted according to the request data type of the related LCM operation. The following mapping between lcmOperationType and the data type of this attribute shall apply: - INSTANTIATE: InstantiateNsRequest - SCALE: ScaleNsRequest - UPDATE: UpdateNsRequest - HEAL: HealNsRequest - TERMINATE: TerminateNsRequest This attribute shall be present if this data type is returned in a response to reading an individual resource, and may be present according to the chosen attribute selector parameter if this data type is returned in a response to a query of a container resource.\n",
- "type":"string",
- "enum":[
- "INSTANTIATE",
- "SCALE",
- "UPDATE",
- "HEAL",
- "TERMINATE"
- ]
+ "type":"object"
},
"isCancelPending":{
"description":"If the LCM operation occurrence is in \"PROCESSING\" or \"ROLLING_BACK\" state and the operation is being cancelled, this attribute shall be set to true. Otherwise, it shall be set to false.\n",
@@ -19521,7 +19515,8 @@
},
"statusEnteredTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"nsInstanceId":{
"description":"An identifier with the intention of being globally unique.\n",
@@ -19540,7 +19535,8 @@
},
"startTime":{
"description":"Date-time stamp. Representation: String formatted according toas defined by the date-time production in IETF RFC 3339.\n",
- "format":"date-time"
+ "format":"date-time",
+ "type":"string"
},
"isAutomaticInvocation":{
"description":"Set to true if this NS LCM operation occurrence has been automatically triggered by the NFVO. This occurs in the case of auto-scaling, auto-healing and when a nested NS is modified as a result of an operation on its composite NS. Set to false otherwise.\n",
@@ -19548,14 +19544,7 @@
},
"operationParams":{
"description":"Input parameters of the LCM operation. This attribute shall be formatted according to the request data type of the related LCM operation. The following mapping between lcmOperationType and the data type of this attribute shall apply: - INSTANTIATE: InstantiateNsRequest - SCALE: ScaleNsRequest - UPDATE: UpdateNsRequest - HEAL: HealNsRequest - TERMINATE: TerminateNsRequest This attribute shall be present if this data type is returned in a response to reading an individual resource, and may be present according to the chosen attribute selector parameter if this data type is returned in a response to a query of a container resource.\n",
- "type":"string",
- "enum":[
- "INSTANTIATE",
- "SCALE",
- "UPDATE",
- "HEAL",
- "TERMINATE"
- ]
+ "type":"object"
},
"isCancelPending":{
"description":"If the LCM operation occurrence is in \"PROCESSING\" or \"ROLLING_BACK\" state and the operation is being cancelled, this attribute shall be set to true. Otherwise, it shall be set to false.\n",