summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be')
-rw-r--r--vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/Dockerfile13
-rw-r--r--vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/marketplace_tables_postgres.sql16
-rw-r--r--vnfmarket-be/deployment/docker/docker-refrepo/pom.xml5
-rw-r--r--vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/Dockerfile13
-rwxr-xr-xvnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/certgen.sh16
-rw-r--r--vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/nginx.conf14
-rw-r--r--vnfmarket-be/deployment/install/docker-compose.yml14
-rw-r--r--vnfmarket-be/deployment/install/vnfsdk_install.sh16
-rw-r--r--vnfmarket-be/deployment/install/vnfsdk_serv.sh16
-rwxr-xr-xvnfmarket-be/deployment/install/vnfsdk_vm_init.sh16
-rw-r--r--vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_mysql.sql16
-rw-r--r--vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_postgres.sql16
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java340
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/model/VTPTestProfile.java102
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml3
15 files changed, 612 insertions, 4 deletions
diff --git a/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/Dockerfile b/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/Dockerfile
index 704d08c3..57f7493e 100644
--- a/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/Dockerfile
+++ b/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/Dockerfile
@@ -1,3 +1,16 @@
+# Copyright 2020 Huawei 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.
#
# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually.
#
diff --git a/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/marketplace_tables_postgres.sql b/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/marketplace_tables_postgres.sql
index f654efd3..cef3349d 100644
--- a/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/marketplace_tables_postgres.sql
+++ b/vnfmarket-be/deployment/docker/docker-postgres/src/main/docker/marketplace_tables_postgres.sql
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2020 Huawei 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.
+ */
+
CREATE DATABASE "marketplaceDB";
\c marketplaceDB;
diff --git a/vnfmarket-be/deployment/docker/docker-refrepo/pom.xml b/vnfmarket-be/deployment/docker/docker-refrepo/pom.xml
index c181243c..23274d4d 100644
--- a/vnfmarket-be/deployment/docker/docker-refrepo/pom.xml
+++ b/vnfmarket-be/deployment/docker/docker-refrepo/pom.xml
@@ -35,6 +35,7 @@
<properties>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+ <push.docker.image>true</push.docker.image>
<docker.skip>false</docker.skip>
<docker.noCache>true</docker.noCache>
<docker.skip.build>false</docker.skip.build>
@@ -88,7 +89,7 @@
<configuration>
<image>onap/vnfsdk/refrepo</image>
<newName>${docker.push.registry}/onap/vnfsdk/refrepo:${project.version}-${maven.build.timestamp}</newName>
- <pushImage>true</pushImage>
+ <pushImage>${push.docker.image}</pushImage>
<skipDockerTag>false</skipDockerTag>
</configuration>
</execution>
@@ -101,7 +102,7 @@
<configuration>
<image>onap/vnfsdk/refrepo</image>
<newName>${docker.push.registry}/onap/vnfsdk/refrepo:latest</newName>
- <pushImage>true</pushImage>
+ <pushImage>${push.docker.image}</pushImage>
<skipDockerTag>false</skipDockerTag>
</configuration>
</execution>
diff --git a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/Dockerfile b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/Dockerfile
index 85e6205e..65812d67 100644
--- a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/Dockerfile
+++ b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/Dockerfile
@@ -1,3 +1,16 @@
+# Copyright 2020 Huawei 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.
#
# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually.
#
diff --git a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/certgen.sh b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/certgen.sh
index 489e4ee2..ae3d3515 100755
--- a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/certgen.sh
+++ b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/certgen.sh
@@ -1,4 +1,20 @@
#!/bin/sh
+#
+# Copyright 2020 Huawei 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.
+#
+
openssl req -nodes -newkey rsa:2048 -keyout example.key -out example.csr -subj "/C=IN/ST=Bangalore/L=Bangalore/O=Global Security/OU=ONAP/CN=example.com"
openssl x509 -req -in example.csr -signkey example.key -out cert.crt
cp -p cert.crt /etc/nginx/ssl/
diff --git a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/nginx.conf b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/nginx.conf
index ef50c595..f6932812 100644
--- a/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/nginx.conf
+++ b/vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/nginx.conf
@@ -1,3 +1,17 @@
+# Copyright 2020 Huawei 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.
+
daemon off;
#pid /run/nginx.pid;
diff --git a/vnfmarket-be/deployment/install/docker-compose.yml b/vnfmarket-be/deployment/install/docker-compose.yml
index 961b2e38..923aa2a5 100644
--- a/vnfmarket-be/deployment/install/docker-compose.yml
+++ b/vnfmarket-be/deployment/install/docker-compose.yml
@@ -1,3 +1,17 @@
+# Copyright 2020 Huawei 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.
+
version: '2'
networks:
default:
diff --git a/vnfmarket-be/deployment/install/vnfsdk_install.sh b/vnfmarket-be/deployment/install/vnfsdk_install.sh
index e43f200a..09b2947f 100644
--- a/vnfmarket-be/deployment/install/vnfsdk_install.sh
+++ b/vnfmarket-be/deployment/install/vnfsdk_install.sh
@@ -1,5 +1,19 @@
#!/bin/bash
-
+#
+# Copyright 2020 Huawei 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.
+#
# Read configuration files
NEXUS_REPO=$(cat /opt/config/nexus_repo.txt)
ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt)
diff --git a/vnfmarket-be/deployment/install/vnfsdk_serv.sh b/vnfmarket-be/deployment/install/vnfsdk_serv.sh
index f91a4d43..0a2c1377 100644
--- a/vnfmarket-be/deployment/install/vnfsdk_serv.sh
+++ b/vnfmarket-be/deployment/install/vnfsdk_serv.sh
@@ -1,4 +1,20 @@
#!/bin/sh
+#
+# Copyright 2020 Huawei 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.
+#
+
### BEGIN INIT INFO
# Provides:
# Required-Start: $remote_fs $syslog
diff --git a/vnfmarket-be/deployment/install/vnfsdk_vm_init.sh b/vnfmarket-be/deployment/install/vnfsdk_vm_init.sh
index a3bcba8a..68182699 100755
--- a/vnfmarket-be/deployment/install/vnfsdk_vm_init.sh
+++ b/vnfmarket-be/deployment/install/vnfsdk_vm_init.sh
@@ -1,4 +1,20 @@
#!/bin/bash
+#
+# Copyright 2020 Huawei 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.
+#
+
# Starts docker containers for VNFSDK VNF repository.
# Version for Amsterdam/R1 uses docker-compose.
diff --git a/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_mysql.sql b/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_mysql.sql
index 7b84b18c..9df95b84 100644
--- a/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_mysql.sql
+++ b/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_mysql.sql
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2020 Huawei 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.
+ */
+
CREATE DATABASE marketplaceDB;
USE marketplaceDB;
diff --git a/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_postgres.sql b/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_postgres.sql
index f654efd3..cef3349d 100644
--- a/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_postgres.sql
+++ b/vnfmarket-be/deployment/zip/src/main/release/init/marketplace_tables_postgres.sql
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2020 Huawei 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.
+ */
+
CREATE DATABASE "marketplaceDB";
\c marketplaceDB;
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java
new file mode 100644
index 00000000..880bfefa
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java
@@ -0,0 +1,340 @@
+/**
+ * Copyright 2018 Huawei 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.
+ */
+
+package org.onap.vtp.profile;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.vtp.VTPResource;
+import org.onap.vtp.error.VTPError;
+import org.onap.vtp.error.VTPError.VTPException;
+import org.onap.vtp.profile.model.VTPTestProfile;
+import org.onap.vtp.profile.model.VTPTestProfile.VTPTestProfileList;
+import org.onap.vtp.profile.model.VTPTestProfile.VTPTestProfileProperty;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+@Path("/vtp")
+@Api(tags = {"VTP Envrionment Profile"})
+public class VTPProfileResource extends VTPResource {
+
+ public VTPTestProfileList listTestProfilesHandler() throws VTPException, IOException{
+ List<String> args = new ArrayList<>();
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "profile-list", "--format", "json"
+ }));
+
+ JsonObject results = this.makeRpcAndGetJson(args).getAsJsonObject();
+
+ VTPTestProfileList list = new VTPTestProfileList();
+
+ if (results != null && results.isJsonArray() && results.getAsJsonArray().size() > 0) {
+ JsonArray resultsArray = results.getAsJsonArray();
+ for (Iterator<JsonElement> it = resultsArray.iterator(); it.hasNext();) {
+ JsonElement jsonElement = it.next();
+ JsonObject n = jsonElement.getAsJsonObject();
+ list.getTestProfiles().add(new VTPTestProfile().setName(n.get("profile").getAsString()));
+ }
+ }
+
+ return list;
+ }
+
+ @Path("/profiles")
+ @GET
+ @ApiOperation(tags = "VTP Envrionment Profile", value = "List available profiles", response = VTPTestProfile.class, responseContainer = "List")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response listTestProfiles() throws VTPException, IOException {
+ return Response.ok(this.listTestProfilesHandler().getTestProfiles().toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public VTPTestProfile getTestProfileHandler(String profileName) throws VTPException, IOException {
+ List<String> args = new ArrayList<>();
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "profile-show", "--profile", profileName, "--format", "json"
+ }));
+ JsonObject results = this.makeRpcAndGetJson(args).getAsJsonObject();
+
+ VTPTestProfile profile = new VTPTestProfile();
+ profile.setName(profileName);
+
+ if (results != null && results.isJsonArray() && results.getAsJsonArray().size() > 0) {
+ JsonArray resultsArray = results.getAsJsonArray();
+ for (Iterator<JsonElement> it = resultsArray.iterator(); it.hasNext();) {
+ JsonElement jsonElement = it.next();
+ JsonObject n = jsonElement.getAsJsonObject();
+ VTPTestProfileProperty prp = new VTPTestProfileProperty();
+
+ prp.setInputParameterName(n.get("parameter").getAsString());
+ prp.setValue(n.get("value").getAsString());
+
+ if (n.get("service") != null && !n.get("service").getAsString().equals("*"))
+ prp.setTestSuiteName(n.get("service").getAsString());
+
+ if (n.get("command") != null && !n.get("command").getAsString().equals("*"))
+ prp.setTestCaseName(n.get("command").getAsString());
+
+ if (n.get("product") != null && !n.get("product").getAsString().equals("*"))
+ prp.setScenario(n.get("product").getAsString());
+
+ profile.getProperties().add(prp);
+ }
+ }
+
+ return profile;
+ }
+
+ @Path("/profiles/{profileName}")
+ @GET
+ @ApiOperation(tags = "VTP Envrionment Profile", value = " Retrieve profile details", response = VTPTestProfile.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation", response = VTPError.class),
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404,
+ message = "Test profile does not exist", response = VTPError.class)})
+ public Response getTestProfile(
+ @ApiParam(value = "Test profile name") @PathParam("profileName") String profileName)
+ throws IOException, VTPException {
+ return Response.ok(this.getTestProfileHandler(profileName).toString(), MediaType.APPLICATION_JSON).build();
+ }
+
+ public void setPofileHanlder(VTPTestProfile profile) throws VTPException, IOException {
+ List<String> args = new ArrayList<>();
+
+
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "profile-set", "--format", "json", "--profile", profile.getName()
+ }));
+
+ Map<String, List<String>> productVsProfile = new HashMap<>();
+
+ for (VTPTestProfileProperty prp: profile.getProperties()) {
+ String scenario = prp.getScenario();
+
+ if (prp.getScenario() == null ) {
+ scenario = "__global__";
+ }
+
+ if (productVsProfile.get(scenario) == null) {
+ productVsProfile.put(scenario, new ArrayList<String>());
+ }
+
+ if ((prp.getInputParameterName() != null) && !prp.getInputParameterName().isEmpty() &&
+ (prp.getValue() != null) && !prp.getValue().isEmpty()) {
+
+ String paramName = "";
+ if (prp.getTestSuiteName() != null && !prp.getTestSuiteName().isEmpty()) {
+ paramName += prp.getTestSuiteName() + ":";
+
+ if (prp.getTestCaseName() != null && !prp.getTestCaseName().isEmpty()) {
+ paramName += prp.getTestCaseName() + ":";
+ }
+ }
+
+ paramName += prp.getInputParameterName();
+
+ productVsProfile.get(scenario).add("--parameter");
+ productVsProfile.get(scenario).add(paramName + "=" + prp.getValue());
+ }
+ }
+
+ for (String scenario: productVsProfile.keySet()) {
+ List<String> arguments = new ArrayList<>();
+ arguments.addAll(args);
+ arguments.addAll(productVsProfile.get(scenario));
+
+ if (!scenario.equals("__global__")) { //profile is set across.
+ arguments.add("--product");
+ arguments.add(scenario);
+ }
+
+ this.makeRpcAndGetJson(arguments);
+ }
+ }
+
+ public void unsetPofileHanlder(VTPTestProfile profile) throws VTPException, IOException {
+ List<String> args = new ArrayList<>();
+
+
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "profile-unset", "--format", "json", "--profile", profile.getName()
+ }));
+
+ Map<String, List<String>> productVsProfile = new HashMap<>();
+
+ for (VTPTestProfileProperty prp: profile.getProperties()) {
+ String scenario = prp.getScenario();
+
+ if (prp.getScenario() == null ) {
+ scenario = "__global__";
+ }
+
+ if (productVsProfile.get(scenario) == null) {
+ productVsProfile.put(scenario, new ArrayList<String>());
+ }
+
+ if ((prp.getInputParameterName() != null) && !prp.getInputParameterName().isEmpty() &&
+ ((prp.getValue() == null) || prp.getValue().isEmpty())) {
+
+ String paramName = "";
+ if (prp.getTestSuiteName() != null && !prp.getTestSuiteName().isEmpty()) {
+ paramName += prp.getTestSuiteName() + ":";
+
+ if (prp.getTestCaseName() != null && !prp.getTestCaseName().isEmpty()) {
+ paramName += prp.getTestCaseName() + ":";
+ }
+ }
+
+ paramName += prp.getInputParameterName();
+
+ productVsProfile.get(scenario).add("--parameter");
+ productVsProfile.get(scenario).add(paramName);
+ }
+ }
+
+ for (String scenario: productVsProfile.keySet()) {
+
+ if (productVsProfile.get(scenario).size() == 0) continue;
+
+ List<String> arguments = new ArrayList<>();
+ arguments.addAll(args);
+ arguments.addAll(productVsProfile.get(scenario));
+
+ if (!scenario.equals("__global__")) { //profile is set across.
+ arguments.add("--product");
+ arguments.add(scenario);
+ }
+
+ this.makeRpcAndGetJson(arguments);
+ }
+ }
+
+ @Path("/profiles")
+ @POST
+ @ApiOperation(tags = "VTP Envrionment Profile", value = "Create profile.")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class),
+ @ApiResponse(code = HttpStatus.CONFLICT_409,
+ message = "Test profile does already exist with given name", response = VTPError.class) })
+ public Response createProfile(@Context HttpServletRequest request) throws VTPException, IOException {
+
+ VTPTestProfile profile = new Gson().fromJson(IOUtils.toString(request.getInputStream()), VTPTestProfile.class);
+
+ for (VTPTestProfile p: this.listTestProfilesHandler().getTestProfiles()) {
+ if (p.getName().equalsIgnoreCase(profile.getName())) {
+ throw new VTPException(
+ new VTPError().setMessage("Test profile does already exist with given name").setHttpStatus(HttpStatus.CONFLICT_409));
+ }
+ }
+
+ this.setPofileHanlder(profile);
+
+ return Response.ok().build();
+ }
+
+ @Path("/profiles/{profileName}")
+ @PUT
+ @ApiOperation(tags = "VTP Envrionment Profile", value = "Update profile. To remove a profile parameter, set its value to null or empty.")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation",
+ response = VTPError.class) })
+ public Response updateProfile(
+ @ApiParam(value = "Test profile name") @PathParam("profileName") String profileName,
+ @Context HttpServletRequest request) throws VTPException, IOException {
+
+ VTPTestProfile profile = new Gson().fromJson(IOUtils.toString(request.getInputStream()), VTPTestProfile.class);
+ if (profile.getName() != null && !profile.getName().equalsIgnoreCase(profileName)) {
+ //TODO: rename profile
+ }
+
+ profile.setName(profileName);
+
+ //Unset those params which value is null or empty.
+ this.unsetPofileHanlder(profile);
+
+ //Set profile
+ this.setPofileHanlder(profile);
+
+ return Response.ok().build();
+ }
+
+ public void deleteProfileHandler(String profileName) throws VTPException, IOException {
+ List<String> args = new ArrayList<>();
+ args.addAll(Arrays.asList(new String[] {
+ "--product", "open-cli", "profile-delete", "--profile", profileName, "--format", "json"
+ }));
+ this.makeRpcAndGetJson(args);
+ }
+
+ @Path("/profiles/{profileName}")
+ @DELETE
+ @ApiOperation(tags = "VTP Envrionment Profile", value = "Delete profile")
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Failed to perform the operation", response = VTPError.class),
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404,
+ message = "Test profile does not exist", response = VTPError.class)})
+ public Response deleteProfile(
+ @ApiParam(value = "Test profile name") @PathParam("profileName") String profileName)
+ throws IOException, VTPException {
+
+ this.deleteProfileHandler(profileName);
+
+ return Response.status(HttpStatus.NO_CONTENT_204).build();
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/model/VTPTestProfile.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/model/VTPTestProfile.java
new file mode 100644
index 00000000..a9604692
--- /dev/null
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/model/VTPTestProfile.java
@@ -0,0 +1,102 @@
+/**
+ * Copyright 2019 Huawei 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.
+ */
+
+package org.onap.vtp.profile.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.vtp.VTPModelBase;
+
+public class VTPTestProfile extends VTPModelBase{
+ private String name;
+ private List<VTPTestProfileProperty> properties = new ArrayList<>();
+
+ public String getName() {
+ return name;
+ }
+
+ public VTPTestProfile setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public List<VTPTestProfileProperty> getProperties() {
+ return properties;
+ }
+
+ public VTPTestProfile setProperties(List<VTPTestProfileProperty> properties) {
+ this.properties = properties;
+ return this;
+ }
+
+ public static class VTPTestProfileList extends VTPModelBase {
+ List <VTPTestProfile> testProfiles = new ArrayList<>();
+
+ public List<VTPTestProfile> getTestProfiles() {
+ return testProfiles;
+ }
+
+ public VTPTestProfileList setTestProfiles(List<VTPTestProfile> testProfiles) {
+ this.testProfiles = testProfiles;
+ return this;
+ }
+ }
+
+ public static class VTPTestProfileProperty extends VTPModelBase {
+ private String scenario;
+ private String testSuiteName;
+ private String testCaseName;
+ private String inputParameterName;
+ private String value;
+ public String getTestSuiteName() {
+ return testSuiteName;
+ }
+ public VTPTestProfileProperty setTestSuiteName(String testSuiteName) {
+ this.testSuiteName = testSuiteName;
+ return this;
+ }
+ public String getTestCaseName() {
+ return testCaseName;
+ }
+ public VTPTestProfileProperty setTestCaseName(String testCaseName) {
+ this.testCaseName = testCaseName;
+ return this;
+ }
+ public String getInputParameterName() {
+ return inputParameterName;
+ }
+ public VTPTestProfileProperty setInputParameterName(String inputParameterName) {
+ this.inputParameterName = inputParameterName;
+ return this;
+ }
+ public String getValue() {
+ return value;
+ }
+ public VTPTestProfileProperty setValue(String value) {
+ this.value = value;
+ return this;
+ }
+
+ public String getScenario() {
+ return scenario;
+ }
+ public VTPTestProfileProperty setScenario(String scenario) {
+ this.scenario = scenario;
+ return this;
+ }
+ }
+}
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
index da5ee65f..cd22a010 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml
@@ -11,7 +11,8 @@
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>io.swagger.jaxrs.listing,
org.onap.vnfsdk.marketplace.resource,
- org.onap.vtp.error,
+ org.onap.vtp.error,
+ org.onap.vtp.profile,
org.onap.vtp.scenario,
org.onap.vtp.execution
</param-value>