From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- .../WEB-INF/jboss-deployment-structure.xml | 42 +- .../WebContent/WEB-INF/jboss-web.xml | 3 - .../mso-vfc-adapter/WebContent/WEB-INF/web.xml | 109 ----- adapters/mso-vfc-adapter/pom.xml | 97 +++- .../java/org/onap/so/adapters/vfc/AaiUtil.java | 47 ++ .../onap/so/adapters/vfc/HealthCheckHandler.java | 65 +++ .../org/onap/so/adapters/vfc/VfcAdapterRest.java | 225 ++++++++++ .../java/org/onap/so/adapters/vfc/VfcManager.java | 496 +++++++++++++++++++++ .../vfc/application/JerseyConfiguration.java | 60 +++ .../vfc/application/MSOVfcApplication.java | 40 ++ .../so/adapters/vfc/constant/CommonConstant.java | 140 ++++++ .../adapters/vfc/constant/DriverExceptionID.java | 64 +++ .../onap/so/adapters/vfc/constant/HttpCode.java | 92 ++++ .../vfc/exceptions/ApplicationException.java | 76 ++++ .../onap/so/adapters/vfc/model/CustomerModel.java | 70 +++ .../so/adapters/vfc/model/LocationConstraint.java | 73 +++ .../vfc/model/NSResourceInputParameter.java | 154 +++++++ .../onap/so/adapters/vfc/model/NsCreateReq.java | 102 +++++ .../so/adapters/vfc/model/NsInstantiateReq.java | 50 +++ .../onap/so/adapters/vfc/model/NsOperationKey.java | 141 ++++++ .../onap/so/adapters/vfc/model/NsParameters.java | 69 +++ .../so/adapters/vfc/model/NsProgressStatus.java | 84 ++++ .../so/adapters/vfc/model/NsScaleParameters.java | 66 +++ .../org/onap/so/adapters/vfc/model/NsScaleReq.java | 49 ++ .../so/adapters/vfc/model/ResponseDescriptor.java | 113 +++++ .../so/adapters/vfc/model/RestfulResponse.java | 101 +++++ .../so/adapters/vfc/model/ScaleNsByStepsData.java | 88 ++++ .../onap/so/adapters/vfc/model/ScaleNsData.java | 49 ++ .../onap/so/adapters/vfc/model/VFCScaleData.java | 82 ++++ .../onap/so/adapters/vfc/model/VimLocation.java | 51 +++ .../org/onap/so/adapters/vfc/util/JsonUtil.java | 134 ++++++ .../org/onap/so/adapters/vfc/util/RestfulUtil.java | 215 +++++++++ .../onap/so/adapters/vfc/util/ValidateUtil.java | 87 ++++ .../org/openecomp/mso/adapters/vfc/AaiUtil.java | 46 -- .../mso/adapters/vfc/HealthCheckHandler.java | 74 --- .../openecomp/mso/adapters/vfc/VfcAdapterRest.java | 220 --------- .../org/openecomp/mso/adapters/vfc/VfcManager.java | 493 -------------------- .../mso/adapters/vfc/constant/CommonConstant.java | 139 ------ .../adapters/vfc/constant/DriverExceptionID.java | 64 --- .../mso/adapters/vfc/constant/HttpCode.java | 91 ---- .../vfc/exceptions/ApplicationException.java | 76 ---- .../mso/adapters/vfc/model/CustomerModel.java | 69 --- .../mso/adapters/vfc/model/LocationConstraint.java | 72 --- .../vfc/model/NSResourceInputParameter.java | 152 ------- .../mso/adapters/vfc/model/NsCreateReq.java | 101 ----- .../mso/adapters/vfc/model/NsInstantiateReq.java | 49 -- .../mso/adapters/vfc/model/NsOperationKey.java | 141 ------ .../mso/adapters/vfc/model/NsParameters.java | 68 --- .../mso/adapters/vfc/model/NsProgressStatus.java | 83 ---- .../mso/adapters/vfc/model/NsScaleParameters.java | 66 --- .../mso/adapters/vfc/model/NsScaleReq.java | 49 -- .../mso/adapters/vfc/model/ResponseDescriptor.java | 112 ----- .../mso/adapters/vfc/model/RestfulResponse.java | 100 ----- .../mso/adapters/vfc/model/ScaleNsByStepsData.java | 88 ---- .../mso/adapters/vfc/model/ScaleNsData.java | 49 -- .../mso/adapters/vfc/model/VFCScaleData.java | 82 ---- .../mso/adapters/vfc/model/VimLocation.java | 50 --- .../openecomp/mso/adapters/vfc/util/JsonUtil.java | 134 ------ .../mso/adapters/vfc/util/RestfulUtil.java | 214 --------- .../mso/adapters/vfc/util/ValidateUtil.java | 87 ---- .../src/main/resources/application.yaml | 37 ++ .../vfc/exceptions/ApplicationExceptionTest.java | 42 ++ .../so/adapters/vfc/model/CustomerModelTest.java | 49 ++ .../adapters/vfc/model/LocationConstraintTest.java | 49 ++ .../vfc/model/NSResourceInputParameterTest.java | 69 +++ .../so/adapters/vfc/model/NsCreateReqTest.java | 69 +++ .../adapters/vfc/model/NsInstantiateReqTest.java | 39 ++ .../so/adapters/vfc/model/NsOperationKeyTest.java | 79 ++++ .../so/adapters/vfc/model/NsParametersTest.java | 52 +++ .../adapters/vfc/model/NsProgressStatusTest.java | 61 +++ .../adapters/vfc/model/ResponseDescriptorTest.java | 79 ++++ .../so/adapters/vfc/model/RestfulResponseTest.java | 76 ++++ .../so/adapters/vfc/model/VimLocationTest.java | 39 ++ .../openecomp/mso/adapters/vfc/VfcAdapterTest.java | 239 ---------- .../vfc/exceptions/ApplicationExceptionTest.java | 42 -- .../mso/adapters/vfc/model/CustomerModelTest.java | 49 -- .../adapters/vfc/model/LocationConstraintTest.java | 49 -- .../vfc/model/NSResourceInputParameterTest.java | 69 --- .../mso/adapters/vfc/model/NsCreateReqTest.java | 69 --- .../adapters/vfc/model/NsInstantiateReqTest.java | 39 -- .../mso/adapters/vfc/model/NsOperationKeyTest.java | 79 ---- .../mso/adapters/vfc/model/NsParametersTest.java | 52 --- .../adapters/vfc/model/NsProgressStatusTest.java | 61 --- .../adapters/vfc/model/ResponseDescriptorTest.java | 79 ---- .../adapters/vfc/model/RestfulResponseTest.java | 76 ---- .../mso/adapters/vfc/model/VimLocationTest.java | 39 -- .../src/test/resources/application-test.yaml | 6 + .../src/test/resources/json/createNsReq.json | 2 +- .../src/test/resources/json/instantiateNsReq.json | 2 +- .../src/test/resources/logback-test.xml | 5 +- 90 files changed, 3930 insertions(+), 4070 deletions(-) delete mode 100644 adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-web.xml delete mode 100644 adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/HttpCode.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstantiateReq.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsProgressStatus.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleReq.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/HealthCheckHandler.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/HttpCode.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/CustomerModel.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsCreateReq.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReq.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatus.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptor.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/RestfulResponse.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java delete mode 100644 adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java create mode 100644 adapters/mso-vfc-adapter/src/main/resources/application.yaml create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationExceptionTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/CustomerModelTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/LocationConstraintTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameterTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsCreateReqTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReqTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsOperationKeyTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsParametersTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatusTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptorTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/RestfulResponseTest.java delete mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/VimLocationTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/resources/application-test.yaml (limited to 'adapters/mso-vfc-adapter') diff --git a/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml index fb268917f2..70f8299675 100644 --- a/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml +++ b/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -1,21 +1,21 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-web.xml deleted file mode 100644 index e2433a381f..0000000000 --- a/adapters/mso-vfc-adapter/WebContent/WEB-INF/jboss-web.xml +++ /dev/null @@ -1,3 +0,0 @@ - - vfc - \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml deleted file mode 100644 index 66ea46fcc9..0000000000 --- a/adapters/mso-vfc-adapter/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - mso-vfc-adapter - - - resteasy.jndi.resources - java:module/MsoPropertiesFactory,java:module/CloudConfigFactory - - - - log.configuration - logback.vfc.xml - - - mso.configuration - MSO_PROP_VFC_ADAPTER=mso.vfc.properties,MSO_PROP_TOPOLOGY=topology.properties - - - mso.cloud_config.configuration - cloud_config.json=2 - - - resteasy.resources - - org.openecomp.mso.MsoStatusHandler, - org.openecomp.mso.logger.MsoLoggingServlet, - org.openecomp.mso.adapters.vfc.HealthCheckHandler, - org.openecomp.mso.adapters.vfc.VfcAdapterRest - - - - resteasy.servlet.mapping.prefix - /rest - - - Resteasy - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - Resteasy - /rest/* - - - - SiteStatus - SiteStatus APIs - /rest/setStatus/* - POST - - - SiteControl-Client - - - - - RestRequests - Rest Ingress Requests - /rest/v1/vfcadapter/* - DELETE - GET - POST - PUT - - - BPEL-Client - - - - - MSO internal Requests - Internal Requests - /rest/logging/* - /rest/properties/* - POST - GET - - - MSO-Client - - - - BASIC - ApplicationRealm - - - BPEL-Client - - - SiteControl-Client - - - MSO-Client - - - LogFilter - org.openecomp.mso.logger.LogFilter - - - LogFilter - /* - - - check.html - - - diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index f45133c646..6fbfb810ec 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -4,34 +4,86 @@ org.onap.so adapters - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.onap.so.adapters mso-vfc-adapter - war mso-vfc-adapter Web service endpoint for vfc operations - - - - + + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + import + + + ${project.artifactId}-${project.version} - maven-war-plugin - 2.4 + org.springframework.boot + spring-boot-maven-plugin - WebContent - false - true + org.onap.so.adapters.vfc.application.MSOVfcApplication + + + + repackage + + + + + + org.jacoco + jacoco-maven-plugin + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-jersey + + + com.h2database + h2 + test + + + org.webjars + swagger-ui + 3.5.0 + + + io.swagger + swagger-jersey2-jaxrs + 1.5.16 + javax.ws.rs javax.ws.rs-api @@ -64,12 +116,7 @@ jboss-ejb3-ext-api 2.2.0.Final provided - - - org.onap.so - status-control - ${project.version} - + org.onap.so mso-requests-db @@ -79,16 +126,20 @@ commons-io commons-io - - org.glassfish.jersey.core - jersey-common - 2.22.2 - test - javax.servlet javax.servlet-api 3.1.0 + + io.micrometer + micrometer-spring-legacy + 1.0.5 + + + io.micrometer + micrometer-registry-prometheus + 1.0.5 + diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java new file mode 100644 index 0000000000..a4f05158a8 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/AaiUtil.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc; + +import org.onap.so.adapters.vfc.model.RestfulResponse; + +/** + * Implement class of operating aai database table
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +public class AaiUtil { + + public static RestfulResponse addRelation(String globalSubsriberId, String serviceType, + String serviceInstanceId, String resourceInstanceId) { + // sent rest to aai to add relation for service and ns. + + return null; + } + + public static RestfulResponse removeRelation(String globalSubsriberId, String serviceType, + String serviceInstanceId, String resourceInstanceId) { + // sent rest to aai to remove relation between service an ns. + return null; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java new file mode 100644 index 0000000000..8fcf315641 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/HealthCheckHandler.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc; + +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.apache.http.HttpStatus; +import org.onap.so.logger.MsoLogger; +import org.onap.so.utils.UUIDChecker; +import org.springframework.stereotype.Component; + +/** + * Health Check + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +@Path("/") +@Component +public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, HealthCheckHandler.class); + + + private static final String CHECK_HTML = "Health CheckApplication ready"; + + public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK) + .entity (CHECK_HTML) + .build (); + + @HEAD + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck(@QueryParam("requestId") String requestId) { + MsoLogger.setServiceName("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + return HEALTH_CHECK_RESPONSE; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java new file mode 100644 index 0000000000..e07753b33a --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcAdapterRest.java @@ -0,0 +1,225 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.onap.so.adapters.vfc.model.NSResourceInputParameter; +import org.onap.so.adapters.vfc.model.NsOperationKey; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.onap.so.adapters.vfc.util.JsonUtil; +import org.onap.so.adapters.vfc.util.ValidateUtil; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * The rest class for VF-c Adapter
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +@Component +@Path("/v1/vfcadapter") +public class VfcAdapterRest { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, VfcAdapterRest.class); + + @Autowired + private VfcManager driverMgr ; + + public VfcAdapterRest() { + + } + + /** + * Create a NS
+ * + * @param data http request + * @return + * @since ONAP Amsterdam Release + */ + @POST + @Path("/ns") + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public Response createNfvoNs(String data) { + try { + ValidateUtil.assertObjectNotNull(data); + LOGGER.debug("body from request is {}" + data); + NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); + RestfulResponse rsp = driverMgr.createNs(nsInput); + return buildResponse(rsp); + } catch(ApplicationException e) { + LOGGER.debug("ApplicationException: ", e); + return e.buildErrorResponse(); + } + } + + /** + * Delete NS instance
+ * + * @param data The http request + * @param nsInstanceId The NS instance id + * @return response + * @since ONAP Amsterdam Release + */ + @DELETE + @Path("/ns/{nsInstanceId}") + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public Response deleteNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { + try { + + ValidateUtil.assertObjectNotNull(data); + LOGGER.debug("body from request is {}" + data); + NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); + RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId); + return buildResponse(rsp); + } catch(ApplicationException e) { + LOGGER.debug("ApplicationException: ", e); + return e.buildErrorResponse(); + } + } + + /** + * Query Operation job status
+ * + * @param data The Http Request + * @param jobId The job id + * @return + * @since ONAP Amsterdam Release + */ + @POST + @Path("/jobs/{jobId}") + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public Response queryNfvoJobStatus(String data, @PathParam("jobId") String jobId) { + try { + ValidateUtil.assertObjectNotNull(data); + LOGGER.debug("body from request is {}" + data); + NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); + RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId); + return buildResponse(rsp); + } catch(ApplicationException e) { + LOGGER.debug("ApplicationException: ", e); + return e.buildErrorResponse(); + } + } + + /** + * Instantiate NS instance
+ * + * @param data The http request + * @param nsInstanceId The NS instance id + * @return + * @since ONAP Amsterdam Release + */ + @POST + @Path("/ns/{nsInstanceId}/instantiate") + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public Response instantiateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { + try { + ValidateUtil.assertObjectNotNull(data); + LOGGER.debug("body from request is {}" + data); + NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); + RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput); + return buildResponse(rsp); + } catch(ApplicationException e) { + LOGGER.debug("ApplicationException: ", e); + return e.buildErrorResponse(); + } + } + + /** + * Terminate NS instance
+ * + * @param data The http request + * @param nsInstanceId The NS instance id + * @return + * @since ONAP Amsterdam Release + */ + @POST + @Path("/ns/{nsInstanceId}/terminate") + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public Response terminateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { + try { + ValidateUtil.assertObjectNotNull(data); + LOGGER.debug("body from request is {}" + data); + NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); + RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId); + return buildResponse(rsp); + } catch(ApplicationException e) { + LOGGER.debug("ApplicationException: ", e); + return e.buildErrorResponse(); + } + } + + /** + * Scale NS instance + *
+ * + * @param servletReq The http request + * @param nsInstanceId The NS instance id + * @return + * @since ONAP Amsterdam Release + */ + @POST + @Path("/ns/{nsInstanceId}/scale") + @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + public Response scaleNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { + try { + ValidateUtil.assertObjectNotNull(data); + LOGGER.debug("Scale Ns Request Received.Body from request is {}" + data); + NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); + RestfulResponse rsp = driverMgr.scaleNs(nsInstanceId, nsInput); + return buildResponse(rsp); + } catch(ApplicationException e) { + LOGGER.debug("ApplicationException: ", e); + return e.buildErrorResponse(); + } + } + + + /** + * build response from restful response
+ * + * @param rsp general response object + * @return + * @since ONAP Amsterdam Release + */ + private Response buildResponse(RestfulResponse rsp) { + return Response.status(rsp.getStatus()).entity(rsp.getResponseContent()).build(); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java new file mode 100644 index 0000000000..47d3842c03 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/VfcManager.java @@ -0,0 +1,496 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc; + +import java.util.HashMap; +import java.util.Map; + +import org.onap.so.adapters.vfc.constant.CommonConstant; +import org.onap.so.adapters.vfc.constant.CommonConstant.Step; +import org.onap.so.adapters.vfc.constant.DriverExceptionID; +import org.onap.so.adapters.vfc.constant.HttpCode; +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.onap.so.adapters.vfc.model.CustomerModel; +import org.onap.so.adapters.vfc.model.NSResourceInputParameter; +import org.onap.so.adapters.vfc.model.NsCreateReq; +import org.onap.so.adapters.vfc.model.NsInstantiateReq; +import org.onap.so.adapters.vfc.model.NsOperationKey; +import org.onap.so.adapters.vfc.model.NsParameters; +import org.onap.so.adapters.vfc.model.NsProgressStatus; +import org.onap.so.adapters.vfc.model.NsScaleParameters; +import org.onap.so.adapters.vfc.model.ResponseDescriptor; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.onap.so.adapters.vfc.model.VFCScaleData; +import org.onap.so.adapters.vfc.util.JsonUtil; +import org.onap.so.adapters.vfc.util.RestfulUtil; +import org.onap.so.adapters.vfc.util.ValidateUtil; +import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.onap.so.requestsdb.RequestsDbConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Example; +import org.springframework.stereotype.Component; + +/** + * VF-C Manager
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +@Component +public class VfcManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(VfcManager.class); + + /** + * nfvo url map + */ + private static Map nfvoUrlMap; + @Autowired + private ResourceOperationStatusRepository resourceOperationStatusRepository; + + @Autowired + private RestfulUtil restfulUtil; + + static { + nfvoUrlMap = new HashMap<>(); + nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL); + nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL); + nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL); + nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL); + nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL); + nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL); + } + + public VfcManager() { + + } + + /** + * create network service
+ * + * @param segInput input parameters for current node from http request + * @return + * @since ONAP Amsterdam Release + */ + public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException { + + // Step1: get service template by node type + String csarId = segInput.getNsServiceModelUUID(); + // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id" + LOGGER.info("serviceTemplateId is {}, id is {}", csarId, csarId); + + LOGGER.info("create ns -> begin"); + // Step2: Prepare url and method type + String url = getUrl(null, CommonConstant.Step.CREATE); + String methodType = CommonConstant.MethodType.POST; + + // Step3: Prepare restful parameters and options + NsCreateReq oRequest = new NsCreateReq(); + oRequest.setCsarId(csarId); + oRequest.setNsName(segInput.getNsServiceName()); + oRequest.setDescription(segInput.getNsServiceDescription()); + CustomerModel context = new CustomerModel(); + context.setGlobalCustomerId(segInput.getNsOperationKey().getGlobalSubscriberId()); + context.setServiceType(segInput.getNsOperationKey().getServiceType()); + oRequest.setContext(context); + String createReq = JsonUtil.marshal(oRequest); + + // Step4: Call NFVO or SDNO lcm to create ns + RestfulResponse createRsp = restfulUtil.send(url, methodType, createReq); + ValidateUtil.assertObjectNotNull(createRsp); + LOGGER.info("create ns response status is : {}", createRsp.getStatus()); + LOGGER.info("create ns response content is : {}", createRsp.getResponseContent()); + + // Step 5: save resource operation information + ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID()); + status.setStatus(RequestsDbConstant.Status.PROCESSING); + status = resourceOperationStatusRepository.save(status); + if (!HttpCode.isSucess(createRsp.getStatus())) { + LOGGER.error("update segment operation status : fail to create ns"); + status.setProgress("40"); + status.setStatusDescription("NS is created"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(createRsp.getStatus())); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_CREATE_NS); + } + @SuppressWarnings("unchecked") + Map rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class); + String nsInstanceId = rsp.get(CommonConstant.NS_INSTANCE_ID); + if (ValidateUtil.isStrEmpty(nsInstanceId)) { + LOGGER.error("Invalid instanceId from create operation"); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION); + } + LOGGER.info("create ns -> end"); + LOGGER.info("save segment and operaton info -> begin"); + // Step 6: add relation between service and NS + AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(), + segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(), + nsInstanceId); + LOGGER.info("save segment and operation info -> end"); + return createRsp; + } + + /** + * delete network service
+ * + * @param nsOperationKey The operation key of the NS resource + * @param nsInstanceId The NS instance id + * @return + * @since ONAP Amsterdam Release + */ + public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) + throws ApplicationException { + LOGGER.info("delete ns -> begin"); + // Step1: prepare url and methodType + String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE); + String methodType = CommonConstant.MethodType.DELETE; + + // Step2: prepare restful parameters and options + RestfulResponse deleteRsp = restfulUtil.send(url, methodType, ""); + ValidateUtil.assertObjectNotNull(deleteRsp); + LOGGER.info("delete ns response status is : {}", deleteRsp.getStatus()); + LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent()); + LOGGER.info("delete ns -> end"); + + ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); + if (!HttpCode.isSucess(deleteRsp.getStatus())) { + LOGGER.error("fail to delete ns"); + + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(deleteRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_DELETE_NS); + } + + // Step3: remove relation info between service and ns + AaiUtil.removeRelation(nsOperationKey.getGlobalSubscriberId(), nsOperationKey.getServiceType(), + nsOperationKey.getServiceId(), nsInstanceId); + LOGGER.info("delete segment information -> end"); + + // Step4: update service segment operation status + status.setStatus(RequestsDbConstant.Status.FINISHED); + status.setErrorCode(String.valueOf(deleteRsp.getStatus())); + status.setProgress("100"); + status.setStatusDescription("VFC resource deletion finished"); + resourceOperationStatusRepository.save(status); + LOGGER.info("update segment operaton status for delete -> end"); + + return deleteRsp; + + } + + /** + * instantiate network service
+ * + * @param nsInstanceId The NS instance id + * @param segInput input parameters for current node from http request + * @return + * @since ONAP Amsterdam Release + */ + public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) + throws ApplicationException { + // Call the NFVO or SDNO service to instantiate service + LOGGER.info("instantiate ns -> begin"); + + // Step1: Prepare restful parameters and options + NsInstantiateReq oRequest = new NsInstantiateReq(); + oRequest.setNsInstanceId(nsInstanceId); + NsParameters nsParameters = segInput.getNsParameters(); + oRequest.setLocationConstraints(nsParameters.getLocationConstraints()); + oRequest.setAdditionalParamForNs(nsParameters.getAdditionalParamForNs()); + String instReq = JsonUtil.marshal(oRequest); + // Step2: prepare url and + String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE); + String methodType = CommonConstant.MethodType.POST; + + RestfulResponse instRsp = restfulUtil.send(url, methodType, instReq); + ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID()); + ValidateUtil.assertObjectNotNull(instRsp); + if (!HttpCode.isSucess(instRsp.getStatus())) { + LOGGER.error("update segment operation status : fail to instantiate ns"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(instRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_INSTANTIATE_NS); + } + LOGGER.info("instantiate ns response status is : {}", instRsp.getStatus()); + LOGGER.info("instantiate ns response content is : {}", instRsp.getResponseContent()); + ValidateUtil.assertObjectNotNull(instRsp.getResponseContent()); + @SuppressWarnings("unchecked") + Map rsp = JsonUtil.unMarshal(instRsp.getResponseContent(), Map.class); + String jobId = rsp.get(CommonConstant.JOB_ID); + if (ValidateUtil.isStrEmpty(jobId)) { + LOGGER.error("Invalid jobId from instantiate operation"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(instRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION); + } + LOGGER.info("instantiate ns -> end"); + // Step 3: update segment operation job id + LOGGER.info("update resource operation status job id -> begin"); + status.setJobId(jobId); + status.setProgress("100"); + status.setStatusDescription("NS initiation completed."); + resourceOperationStatusRepository.save(status); + LOGGER.info("update segment operation job id -> end"); + + return instRsp; + } + + /** + * terminate network service
+ * + * @param nsOperationKey The operation key for NS resource + * @param nsInstanceId The NS instance id + * @return + * @since ONAP Amsterdam Release + */ + public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) + throws ApplicationException { + // Step1: save segment operation info for delete process + LOGGER.info("save segment operation for delete process"); + ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); + status.setStatus(RequestsDbConstant.Status.PROCESSING); + resourceOperationStatusRepository.save(status); + + LOGGER.info("terminate ns -> begin"); + // Step2: prepare url and method type + String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE); + String methodType = CommonConstant.MethodType.POST; + + // Step3: prepare restful parameters and options + Map reqBody = new HashMap<>(); + reqBody.put("nsInstanceId", nsInstanceId); + reqBody.put("terminationType", "graceful"); + reqBody.put("gracefulTerminationTimeout", "60"); + + // Step4: Call the NFVO or SDNO service to terminate service + RestfulResponse terminateRsp = restfulUtil.send(url, methodType, JsonUtil.marshal(reqBody)); + ValidateUtil.assertObjectNotNull(terminateRsp); + LOGGER.info("terminate ns response status is : {}", terminateRsp.getStatus()); + LOGGER.info("terminate ns response content is : {}", terminateRsp.getResponseContent()); + // Step 3: update segment operation + if (!HttpCode.isSucess(terminateRsp.getStatus())) { + LOGGER.error("fail to instantiate ns"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(terminateRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_TERMINATE_NS); + } + @SuppressWarnings("unchecked") + Map rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class); + String jobId = rsp.get(CommonConstant.JOB_ID); + if (ValidateUtil.isStrEmpty(jobId)) { + LOGGER.error("Invalid jobId from terminate operation"); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setErrorCode(String.valueOf(terminateRsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.INVALID_RESPONSE_FROM_TERMINATE_OPERATION); + } + LOGGER.info("terminate ns -> end"); + + LOGGER.info("update segment job id -> begin"); + status.setProgress("60"); + status.setStatusDescription("NS is termination completed"); + status.setJobId(jobId); + resourceOperationStatusRepository.save(status); + LOGGER.info("update segment job id -> end"); + + return terminateRsp; + } + + /** + * get ns progress by job Id
+ * + * @param nsOperationKey The OperationKey for NS resource + * @param jobId the job id + * @return + * @since ONAP Amsterdam Release + */ + public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) + throws ApplicationException { + + ValidateUtil.assertObjectNotNull(jobId); + // Step 1: query the current resource operation status + ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(), nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); + status = resourceOperationStatusRepository.findOne(Example.of(status)); + // Step 2: start query + LOGGER.info("query ns status -> begin"); + String url = getUrl(jobId, CommonConstant.Step.QUERY); + String methodType = CommonConstant.MethodType.GET; + // prepare restful parameters and options + RestfulResponse rsp = restfulUtil.send(url, methodType, ""); + ValidateUtil.assertObjectNotNull(rsp); + LOGGER.info("query ns progress response status is : {}", rsp.getStatus()); + LOGGER.info("query ns progress response content is : {}", rsp.getResponseContent()); + // Step 3:check the response staus + if (!HttpCode.isSucess(rsp.getStatus())) { + LOGGER.info("fail to query job status"); + status.setErrorCode(String.valueOf(rsp.getStatus())); + status.setStatus(RequestsDbConstant.Status.ERROR); + status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS); + } + // Step 4: Process Network Service Instantiate Response + NsProgressStatus nsProgress = + JsonUtil.unMarshal(rsp.getResponseContent(), NsProgressStatus.class); + ResponseDescriptor rspDesc = nsProgress.getResponseDescriptor(); + // Step 5: update segment operation progress + + status.setProgress(rspDesc.getProgress()); + status.setStatusDescription(rspDesc.getStatusDescription()); + resourceOperationStatusRepository.save(status); + + // Step 6: update segment operation status + if (RequestsDbConstant.Progress.ONE_HUNDRED.equals(rspDesc.getProgress()) + && RequestsDbConstant.Status.FINISHED.equals(rspDesc.getStatus())) { + LOGGER.info("job result is succeeded, operType is {}", status.getOperType()); + status.setErrorCode(String.valueOf(rsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED); + + if(RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase(status.getOperType()) || "createInstance".equalsIgnoreCase (status.getOperType())) { + status.setStatus(RequestsDbConstant.Status.FINISHED); + } + resourceOperationStatusRepository.save(status); + } else if (RequestsDbConstant.Status.ERROR.equals(rspDesc.getStatus())) { + LOGGER.error("job result is failed, operType is {}", status.getOperType()); + status.setErrorCode(String.valueOf(rsp.getStatus())); + status.setStatusDescription(CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED); + status.setStatus(RequestsDbConstant.Status.ERROR); + resourceOperationStatusRepository.save(status); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.JOB_STATUS_ERROR); + } else { + LOGGER.error("unexcepted response status"); + } + LOGGER.info("query ns status -> end"); + + return rsp; + } + + /** + * Scale NS instance + *
+ * + * @param nsInstanceId The NS instance id + * @param segInput input parameters for current node from http request + * @return + * @since ONAP Amsterdam Release + */ + public RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput) + throws ApplicationException { + // Call the NFVO to scale service + LOGGER.info("scale ns -> begin"); + + // Step1: Prepare restful parameters and options + VFCScaleData oRequest = new VFCScaleData(); + oRequest.setNsInstanceId(nsInstanceId); + NsScaleParameters nsScaleParameters = segInput.getNsScaleParameters(); + oRequest.setScaleType(nsScaleParameters.getScaleType()); + oRequest.setScaleNsData(nsScaleParameters.getScaleNsByStepsData()); + String scaleReq = JsonUtil.marshal(oRequest); + + // Step2: prepare url and method type + String url = getUrl(nsInstanceId, CommonConstant.Step.SCALE); + String methodType = CommonConstant.MethodType.POST; + LOGGER.info("scale ns request is {}", scaleReq); + // Step3: Call NFVO lcm to scale ns + RestfulResponse scaleRsp = restfulUtil.send(url, methodType, scaleReq); + + ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID()); + ResourceOperationStatus nsOperInfo = resourceOperationStatusRepository.findOne(Example.of(status)); + ValidateUtil.assertObjectNotNull(scaleRsp); + if(!HttpCode.isSucess(scaleRsp.getStatus())) { + LOGGER.error("update segment operation status : fail to scale ns"); + nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); + nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus())); + nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED); + resourceOperationStatusRepository.save(nsOperInfo); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_SCALE_NS); + } + LOGGER.info("scale ns response status is {}", scaleRsp.getStatus()); + LOGGER.info("scale ns response content is {}", scaleRsp.getResponseContent()); + + ValidateUtil.assertObjectNotNull(scaleRsp.getResponseContent()); + @SuppressWarnings("unchecked") + Map rsp = JsonUtil.unMarshal(scaleRsp.getResponseContent(), Map.class); + String jobId = rsp.get(CommonConstant.JOB_ID); + if(ValidateUtil.isStrEmpty(jobId)) { + LOGGER.error("Invalid jobId from scale operation"); + nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); + nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus())); + nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED); + resourceOperationStatusRepository.save(nsOperInfo); + throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, + DriverExceptionID.INVALID_RESPONSE_FROM_SCALE_OPERATION); + } + + LOGGER.info("update resource operation status job id -> begin"); + // Step 4: update segment operation job id + nsOperInfo.setJobId(jobId); + resourceOperationStatusRepository.save(nsOperInfo); + LOGGER.info("update segment operation job id -> end"); + LOGGER.info("scale ns -> end"); + + return scaleRsp; + } + + /** + * get url for the operation
+ * + * @param variable variable should be put in the url + * @param step step of the operation (terminate,query,delete) + * @return + * @since ONAP Amsterdam Release + */ + private String getUrl(String variable, String step) { + + String url; + String originalUrl; + originalUrl = nfvoUrlMap.get(step); + url = String.format(originalUrl, variable); + return url; + + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java new file mode 100644 index 0000000000..a97549189d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/JerseyConfiguration.java @@ -0,0 +1,60 @@ +/*- + * ============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.adapters.vfc.application; + +import javax.annotation.PostConstruct; +import javax.ws.rs.ApplicationPath; + +import org.glassfish.jersey.server.ResourceConfig; +import org.onap.so.adapters.vfc.HealthCheckHandler; +import org.onap.so.adapters.vfc.VfcAdapterRest; +import org.springframework.context.annotation.Configuration; + +import io.swagger.jaxrs.config.BeanConfig; +import io.swagger.jaxrs.listing.ApiListingResource; +import io.swagger.jaxrs.listing.SwaggerSerializers; + +@Configuration +@ApplicationPath("/vfc") +public class JerseyConfiguration extends ResourceConfig { + + public JerseyConfiguration() { + + } + + @PostConstruct + public void setUp() { + register(VfcAdapterRest.class); + register(HealthCheckHandler.class); + + this.register(ApiListingResource.class); + this.register(SwaggerSerializers.class); + + BeanConfig beanConfig = new BeanConfig(); + beanConfig.setVersion("1.0.2"); + beanConfig.setSchemes(new String[] { "http" }); + beanConfig.setHost("localhost:8080"); + beanConfig.setBasePath("/"); + beanConfig.setResourcePackage("org.onap.so.adapters.vfc.application"); + beanConfig.setPrettyPrint(true); + beanConfig.setScan(true); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java new file mode 100644 index 0000000000..c6d141391d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/application/MSOVfcApplication.java @@ -0,0 +1,40 @@ +/*- + * ============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.adapters.vfc.application; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + + + +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@EnableJpaRepositories({"org.onap.so.db.request.data.repository"}) +@EntityScan({"org.onap.so.db.request.beans"}) +public class MSOVfcApplication { + + public static void main(String... args) { + SpringApplication.run(MSOVfcApplication.class, args); + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java new file mode 100644 index 0000000000..128dc52d36 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/CommonConstant.java @@ -0,0 +1,140 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.constant; + +/** + * CommonConstant + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ +public class CommonConstant { + + public static final String STR_EMPTY = ""; + + public static final String NFVO_CREATE_URL = "/api/nslcm/v1/ns"; + + public static final String NFVO_INSTANTIATE_URL = "/api/nslcm/v1/ns/%s/instantiate"; + + public static final String NFVO_TERMINATE_URL = "/api/nslcm/v1/ns/%s/terminate"; + + public static final String NFVO_DELETE_URL = "/api/nslcm/v1/ns/%s"; + + public static final String NFVO_QUERY_URL = "/api/nslcm/v1/jobs/%s"; + + public static final String NFVO_SCALE_URL = "/api/nslcm/v1/ns/%s/scale"; + + /** + * + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ + public static class MethodType { + + public static final String POST = "post"; + + public static final String DELETE = "delete"; + + public static final String PUT = "put"; + + public static final String GET = "get"; + + private MethodType() { + + } + } + + /** + * + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-28 + */ + public static class Step { + + public static final String CREATE = "create"; + + public static final String INSTANTIATE = "instantiate"; + + public static final String STATUS = "status"; + + public static final String TERMINATE = "terminate"; + + public static final String QUERY = "query"; + + public static final String DELETE = "delete"; + + public static final String SCALE = "scale"; + + private Step() { + + } + + } + + + public static final String NSD_ID = "nsdId"; + + public static final String NS_NAME = "nsName"; + + public static final String DESC = "description"; + + public static final String NS_INSTANCE_ID = "nsInstanceId"; + + public static final String JOB_ID = "jobId"; + + public static final String ADDITIONAL_PARAM_FOR_NS = "additionalParamForNs"; + + public static final String LOCAL_HOST = "localhost"; + + public static class StatusDesc { + + public static final String INSTANTIATE_NS_FAILED = "instantiate ns failed"; + + public static final String QUERY_JOB_STATUS_FAILED = "query job status failed"; + + public static final String TERMINATE_NS_FAILED = "terminate ns failed"; + + public static final String DELETE_NS_FAILED = "delete ns failed"; + + public static final String CREATE_NS_FAILED = "create ns failed"; + + public static final String SCALE_NS_FAILED = "scale ns failed"; + + private StatusDesc() { + + } + } + + private CommonConstant() { + + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java new file mode 100644 index 0000000000..f82a38e324 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/DriverExceptionID.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.constant; + +/** + *
+ *

+ *

+ * identification of adapter exception + * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +public class DriverExceptionID { + + public static final String INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION = + "Invalid response from instantiate operation"; + + public static final String INVALID_RESPONSEE_FROM_CREATE_OPERATION = + "Invalid response from create operation"; + + public static final String FAIL_TO_INSTANTIATE_NS = "Fail to instantiate ns"; + + public static final String FAIL_TO_CREATE_NS = "Fail to create ns"; + + public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION = + "Invalid response from terminate operation"; + + public static final String FAIL_TO_DELETE_NS = "Fail to delete ns"; + + public static final String FAIL_TO_TERMINATE_NS = "Fail to terminate ns"; + + public static final String JOB_STATUS_ERROR = "Job status error"; + + public static final String FAIL_TO_QUERY_JOB_STATUS = "Fail to query job status"; + + public static final String FAIL_TO_SCALE_NS = "Fail to scale network service"; + + public static final String INVALID_RESPONSE_FROM_SCALE_OPERATION = "Invalid response from scale operation"; + + + private DriverExceptionID() { + + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/HttpCode.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/HttpCode.java new file mode 100644 index 0000000000..e08c1573cc --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/constant/HttpCode.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.constant; + +/** + * Constant Class.
+ *

+ * Define constant for http operation. + *

+ * + * @author + * @version ONAP Amsterdam 2016/8/4 + */ +public class HttpCode { + + /** + * Fail to request. + */ + public static final int BAD_REQUEST = 400; + + /** + * Inner error + */ + public static final int INTERNAL_SERVER_ERROR = 500; + + /** + * Not accept request. + */ + public static final int NOT_ACCEPTABLE = 406; + + /** + * Not found service. + */ + public static final int NOT_FOUND = 404; + + /** + * Accept request. + */ + public static final int RESPOND_ACCEPTED = 202; + + /** + * Http response is ok. + */ + public static final int RESPOND_OK = 200; + + public static final int CREATED_OK = 201; + + /** + * Conflict + */ + public static final int RESPOND_CONFLICT = 409; + + /** + * Constructor
+ *

+ *

+ * + * @since ONAP Amsterdam Release 2017-9-6 + */ + private HttpCode() { + + } + + /** + * Whether request is successful.
+ * + * @param httpCode response code + * @return true or false + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static boolean isSucess(int httpCode) { + return httpCode / 100 == 2; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java new file mode 100644 index 0000000000..1e712cb76b --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/exceptions/ApplicationException.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.exceptions; + +import javax.ws.rs.core.Response; + +public class ApplicationException extends Exception { + + /** + * Serial number. + */ + private static final long serialVersionUID = 1L; + + private int errorCode; + + private String errorMsg; + + /** + * Constructor
+ *

+ *

+ * + * @param errorCode error status + * @param errorMsg error detail + * @since ONAP Amsterdam Release 2017-9-6 + */ + 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; + } + + /** + * build error Response + *
+ * + * @return + * @since ONAP Amsterdam Release + */ + public Response buildErrorResponse() { + return Response.status(errorCode).entity(errorMsg).build(); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java new file mode 100644 index 0000000000..986d168482 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/CustomerModel.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +/** + * The Customer Model + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-10-12 + */ +public class CustomerModel { + + String globalCustomerId; + + String serviceType; + + + /** + * @return Returns the globalCustomerId. + */ + public String getGlobalCustomerId() { + return globalCustomerId; + } + + + /** + * @param globalCustomerId The globalCustomerId to set. + */ + public void setGlobalCustomerId(String globalCustomerId) { + this.globalCustomerId = globalCustomerId; + } + + + /** + * @return Returns the serviceType. + */ + public String getServiceType() { + return serviceType; + } + + + /** + * @param serviceType The serviceType to set. + */ + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java new file mode 100644 index 0000000000..a28bd9a501 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/LocationConstraint.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +/** + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +public class LocationConstraint { + + /** + * vnf profile id + */ + private String vnfProfileId; + + /** + * location constraints: vimId + */ + private VimLocation locationConstraints; + + /** + * @return Returns the vnfProfileId. + */ + public String getVnfProfileId() { + return vnfProfileId; + } + + /** + * @param vnfProfileId The vnfProfileId to set. + */ + public void setVnfProfileId(String vnfProfileId) { + this.vnfProfileId = vnfProfileId; + } + + + /** + * @return Returns the locationConstraints. + */ + public VimLocation getLocationConstraints() { + return locationConstraints; + } + + + /** + * @param locationConstraints The locationConstraints to set. + */ + public void setLocationConstraints(VimLocation locationConstraints) { + this.locationConstraints = locationConstraints; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java new file mode 100644 index 0000000000..ce5637baa3 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NSResourceInputParameter.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (C) 2018 CMCC 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.vfc.model; + +import java.io.ByteArrayOutputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * NS Create Input Parameter For VFC Adapter
+ *

+ *

+ * + * @version ONAP Amsterdam Release 2017/1/7 + */ +public class NSResourceInputParameter { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, NSResourceInputParameter.class); + + private NsOperationKey nsOperationKey; + + private String nsServiceName; + + private String nsServiceDescription; + + private String nsServiceModelUUID; + + private NsParameters nsParameters; + + private NsScaleParameters nsScaleParameters; + + + /** + * @return Returns the nsServiceName. + */ + public String getNsServiceName() { + return nsServiceName; + } + + + /** + * @param nsServiceName The nsServiceName to set. + */ + public void setNsServiceName(String nsServiceName) { + this.nsServiceName = nsServiceName; + } + + + /** + * @return Returns the nsServiceDescription. + */ + public String getNsServiceDescription() { + return nsServiceDescription; + } + + + /** + * @param nsServiceDescription The nsServiceDescription to set. + */ + public void setNsServiceDescription(String nsServiceDescription) { + this.nsServiceDescription = nsServiceDescription; + } + + /** + * @return Returns the nsParameters. + */ + public NsParameters getNsParameters() { + return nsParameters; + } + + /** + * @param nsParameters The nsParameters to set. + */ + public void setNsParameters(NsParameters nsParameters) { + this.nsParameters = nsParameters; + } + + public NsOperationKey getNsOperationKey() { + return nsOperationKey; + } + + public void setNsOperationKey(NsOperationKey nsOperationKey) { + this.nsOperationKey = nsOperationKey; + } + public String toJsonString() { + String jsonString = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + jsonString = mapper.writeValueAsString(this); + } catch (Exception e) { + LOGGER.debug("Exception:", e); + } + return jsonString; + } + + public String toXmlString() { + try { + ByteArrayOutputStream bs = new ByteArrayOutputStream(); + JAXBContext context = JAXBContext.newInstance(this.getClass()); + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML + marshaller.marshal(this, bs); + return bs.toString(); + } catch (Exception e) { + LOGGER.debug("Exception:", e); + return ""; + } + } + + public NsScaleParameters getNsScaleParameters() { + return nsScaleParameters; + } + + public void setNsScaleParameters(NsScaleParameters nsScaleParameters) { + this.nsScaleParameters = nsScaleParameters; + } + + + public String getNsServiceModelUUID() { + return nsServiceModelUUID; + } + + + public void setNsServiceModelUUID(String nsServiceModelUUID) { + this.nsServiceModelUUID = nsServiceModelUUID; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java new file mode 100644 index 0000000000..2d09f55de2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsCreateReq.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +/** + * Network Service Request
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Sep 2, 2016 + */ +public class NsCreateReq { + + CustomerModel context; + + String csarId; + + String nsName; + + String description; + + + /** + * @return Returns the context. + */ + public CustomerModel getContext() { + return context; + } + + + + /** + * @param context The context to set. + */ + public void setContext(CustomerModel context) { + this.context = context; + } + + + /** + * @return Returns the csarId. + */ + public String getCsarId() { + return csarId; + } + + + /** + * @param csarId The csarId to set. + */ + public void setCsarId(String csarId) { + this.csarId = csarId; + } + + /** + * @return Returns the nsName. + */ + public String getNsName() { + return nsName; + } + + /** + * @param nsName The nsName to set. + */ + public void setNsName(String nsName) { + this.nsName = nsName; + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstantiateReq.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstantiateReq.java new file mode 100644 index 0000000000..4281026021 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsInstantiateReq.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +/** + *
+ *

+ *

+ * request model for instatiate + * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +public class NsInstantiateReq extends NsParameters { + + String nsInstanceId; + + /** + * @return Returns the nsInstanceId. + */ + public String getNsInstanceId() { + return nsInstanceId; + } + + /** + * @param nsInstanceId The nsInstanceId to set. + */ + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java new file mode 100644 index 0000000000..bc67832cb2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsOperationKey.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +/** + * The operation key object for NS + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-09-15 + */ +public class NsOperationKey { + + /** + * The subscriber id + */ + private String globalSubscriberId; + + /** + * The serviceType + */ + private String serviceType; + + /** + * The service ID + */ + private String serviceId; + + /** + * The Operation ID + */ + private String operationId; + + /** + * the NS template uuid + */ + private String nodeTemplateUUID; + + /** + * @return Returns the globalSubscriberId. + */ + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + /** + * @param globalSubscriberId The globalSubscriberId to set. + */ + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + /** + * @return Returns the serviceType. + */ + public String getServiceType() { + return serviceType; + } + + /** + * @param serviceType The serviceType to set. + */ + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + /** + *
+ * + * @return + * @since ONAP Amsterdam Release + */ + public String getServiceId() { + return serviceId; + } + + /** + *
+ * + * @param serviceId + * @since ONAP Amsterdam Release + */ + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + /** + *
+ * + * @return + * @since ONAP Amsterdam Release + */ + public String getOperationId() { + return operationId; + } + + /** + *
+ * + * @param operationId + * @since ONAP Amsterdam Release + */ + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + /** + * @return Returns the nodeTemplateUUID. + */ + public String getNodeTemplateUUID() { + return nodeTemplateUUID; + } + + /** + * @param nodeTemplateUUID The nodeTemplateUUID to set. + */ + public void setNodeTemplateUUID(String nodeTemplateUUID) { + this.nodeTemplateUUID = nodeTemplateUUID; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java new file mode 100644 index 0000000000..5da3d806f1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsParameters.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +public class NsParameters { + + private List locationConstraints; + + private Map additionalParamForNs = new HashMap<>(); + /** + * @return Returns the locationConstraints. + */ + public List getLocationConstraints() { + return locationConstraints; + } + + /** + * @param locationConstraints The locationConstraints to set. + */ + public void setLocationConstraints(List locationConstraints) { + this.locationConstraints = locationConstraints; + } + + + /** + * @return Returns the additionalParamForNs. + */ + public Map getAdditionalParamForNs() { + return additionalParamForNs; + } + + + /** + * @param additionalParamForNs The additionalParamForNs to set. + */ + public void setAdditionalParamForNs(Map additionalParamForNs) { + this.additionalParamForNs = additionalParamForNs; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsProgressStatus.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsProgressStatus.java new file mode 100644 index 0000000000..a7e72efb62 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsProgressStatus.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +import java.util.List; + +/** + *
+ *

+ *

+ * response model of query operation status + * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +public class NsProgressStatus { + + String jobId; + + ResponseDescriptor responseDescriptor; + + List responseHistoryList; + + /** + * @return Returns the jobId. + */ + public String getJobId() { + return jobId; + } + + /** + * @param jobId The jobId to set. + */ + public void setJobId(String jobId) { + this.jobId = jobId; + } + + /** + * @return Returns the responseDescriptor. + */ + public ResponseDescriptor getResponseDescriptor() { + return responseDescriptor; + } + + /** + * @param responseDescriptor The responseDescriptor to set. + */ + public void setResponseDescriptor(ResponseDescriptor responseDescriptor) { + this.responseDescriptor = responseDescriptor; + } + + /** + * @return Returns the responseHistoryList. + */ + public List getResponseHistoryList() { + return responseHistoryList; + } + + /** + * @param responseHistoryList The responseHistoryList to set. + */ + public void setResponseHistoryList(List responseHistoryList) { + this.responseHistoryList = responseHistoryList; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java new file mode 100644 index 0000000000..e4e217a9f5 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleParameters.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 CMCC 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.vfc.model; + +import java.util.List; + +/** + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-9-26 + */ +public class NsScaleParameters { + + private List scaleNsByStepsData; + + private String scaleType; + + /** + * @return Returns the scaleNsByStepsData. + */ + public List getScaleNsByStepsData() { + return scaleNsByStepsData; + } + + /** + * @param scaleNsByStepsData The scaleNsByStepsData to set. + */ + public void setScaleNsByStepsData(List scaleNsByStepsData) { + this.scaleNsByStepsData = scaleNsByStepsData; + } + + /** + * @return Returns the scale Type. + */ + public String getScaleType() { + return scaleType; + } + + /** + * @param scaleType The scaleType to set. + */ + public void setScaleType(String scaleType) { + this.scaleType = scaleType; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleReq.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleReq.java new file mode 100644 index 0000000000..79ed02c69f --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsScaleReq.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 CMCC 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.vfc.model; + +/** + *
+ *

+ *

+ * request model for scale + * + * @author + * @version ONAP Amsterdam Release 2017-9-26 + */ +public class NsScaleReq extends NsScaleParameters { + + String nsInstanceId; + + /** + * @return Returns the nsInstanceId. + */ + public String getNsInstanceId() { + return nsInstanceId; + } + + /** + * @param nsInstanceId The nsInstanceId to set. + */ + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java new file mode 100644 index 0000000000..08e3dcae4f --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ResponseDescriptor.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; +/** + *
+ *

+ *

+ * response model of query operation status + * + * @author + * @version SDNO 0.5 September 3, 2016 + */ +public class ResponseDescriptor { + + String status; + + String progress; + + String statusDescription; + + Integer errorCode; + + Integer responseId; + + /** + * @return Returns the status. + */ + public String getStatus() { + return status; + } + + /** + * @param status The status to set. + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return Returns the progress. + */ + public String getProgress() { + return progress; + } + + /** + * @param progress The progress to set. + */ + public void setProgress(String progress) { + this.progress = progress; + } + + /** + * @return Returns the statusDescription. + */ + public String getStatusDescription() { + return statusDescription; + } + + /** + * @param statusDescription The statusDescription to set. + */ + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + /** + * @return Returns the errorCode. + */ + public Integer getErrorCode() { + return errorCode; + } + + /** + * @param errorCode The errorCode to set. + */ + public void setErrorCode(Integer errorCode) { + this.errorCode = errorCode; + } + + /** + * @return Returns the responseId. + */ + public Integer getResponseId() { + return responseId; + } + + /** + * @param responseId The responseId to set. + */ + public void setResponseId(Integer responseId) { + this.responseId = responseId; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java new file mode 100644 index 0000000000..ee5ecd6e19 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/RestfulResponse.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +import java.util.Map; + +/** + * The Unified Restful Reponse Class + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-09-06 + */ +public class RestfulResponse { + + // the response content + private String responseContent; + + //the response status + private int status; + + //the response header + private Map respHeaderMap; + + public RestfulResponse() { + this.status = -1; + + this.respHeaderMap = null; + } + + public int getStatus() { + return this.status; + } + + public void setStatus(int status) { + this.status = status; + } + + public Map getRespHeaderMap() { + return this.respHeaderMap; + } + + public void setRespHeaderMap(Map header) { + this.respHeaderMap = header; + } + + public int getRespHeaderInt(String key) { + if(this.respHeaderMap != null) { + String result = this.respHeaderMap.get(key); + if(result != null) { + return Integer.parseInt(result); + } + } + return -1; + } + + public long getRespHeaderLong(String key) { + if(this.respHeaderMap != null) { + String result = this.respHeaderMap.get(key); + if(result != null) { + return Long.parseLong(result); + } + } + return -1L; + } + + public String getRespHeaderStr(String key) { + if(this.respHeaderMap != null) { + return this.respHeaderMap.get(key); + } + return null; + } + + public String getResponseContent() { + return this.responseContent; + } + + public void setResponseContent(String responseString) { + this.responseContent = responseString; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java new file mode 100644 index 0000000000..938064d3a2 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsByStepsData.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 CMCC 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.vfc.model; + +/** + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-9-26 + */ +public class ScaleNsByStepsData { + + /** + * scaling Direction + */ + private String scalingDirection; + + /** + * aspect ID + */ + private String aspectId; + + /** + * number of Steps + */ + private Integer numberOfSteps; + + /** + * @return Returns the scalingDirection. + */ + public String getScalingDirection() { + return scalingDirection; + } + + /** + * @param scalingDirection The scalingDirection to set. + */ + public void setScalingDirection(String scalingDirection) { + this.scalingDirection = scalingDirection; + } + + /** + * @return Returns the aspectId. + */ + public String getAspectId() { + return aspectId; + } + + /** + * @param aspectId The aspectId to set. + */ + public void setAspectId(String aspectId) { + this.aspectId = aspectId; + } + + /** + * @return Returns the numberOfSteps. + */ + public Integer getNumberOfSteps() { + return numberOfSteps; + } + + /** + * @param numberOfSteps The numberOfSteps to set. + */ + public void setNumberOfSteps(int numberOfSteps) { + this.numberOfSteps = numberOfSteps; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java new file mode 100644 index 0000000000..b0ad26ae3f --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/ScaleNsData.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC 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.vfc.model; + +import java.util.List; + +/** + * aim to wrap List as a new list + * then be provided for the usage of vfc json + * + * added on 2018/01/30 by Qihui Zhao from CMCC + * */ + +public class ScaleNsData { + + private List scaleNsByStepsData; + + /** + * @return Returns the scaleNsByStepsData. + */ + public List getScaleNsByStepsData() { + return scaleNsByStepsData; + } + + /** + * @param scaleNsByStepsData The scaleNsByStepsData to set. + */ + public void setScaleNsByStepsData(List scaleNsByStepsData) { + this.scaleNsByStepsData = scaleNsByStepsData; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java new file mode 100644 index 0000000000..4a393e1064 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VFCScaleData.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 CMCC 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.vfc.model; + +import java.util.ArrayList; +import java.util.List; + +/** + * Object totally matches required VFC input json format + * JsonUtil.marshal will convert this Object to string + * + * added on 2018/01/30 by Qihui Zhao from CMCC*/ + +public class VFCScaleData { + + private String nsInstanceId; + + private String scaleType; + + private List scaleNsData = new ArrayList<>(); + + /** + * @return Returns the nsInstanceId. + */ + public String getNsInstanceId() { + return nsInstanceId; + } + + /** + * @param nsInstanceId The nsInstanceId to set. + */ + public void setNsInstanceId(String nsInstanceId) { + this.nsInstanceId = nsInstanceId; + } + + /** + * @return Returns the scale Type. + */ + public String getScaleType() { + return scaleType; + } + + /** + * @param scaleType The scaleType to set. + */ + public void setScaleType(String scaleType) { + this.scaleType = scaleType; + } + + /** + *@return Returns the scaleNsDate. + */ + public List getScaleNsData(){return scaleNsData;} + + /** + * The scaleNsData to set. + */ + public void setScaleNsData(List scaleNsByStepsData){ + ScaleNsData scaleNsDataObj = new ScaleNsData(); + scaleNsDataObj.setScaleNsByStepsData(scaleNsByStepsData); + + this.scaleNsData.add(scaleNsDataObj); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java new file mode 100644 index 0000000000..9f6f8ec274 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/VimLocation.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.model; + +/** + * + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-10-18 + */ +public class VimLocation { + private String vimId; + + + /** + * @return Returns the vimId. + */ + public String getVimId() { + return vimId; + } + + + /** + * @param vimId The vimId to set. + */ + public void setVimId(String vimId) { + this.vimId = vimId; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java new file mode 100644 index 0000000000..c12cd7da05 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java @@ -0,0 +1,134 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.util; + +import java.io.IOException; + +import org.onap.so.adapters.vfc.constant.HttpCode; +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Interface for json analyzing.
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +public class JsonUtil { + + /** + * Log service + */ + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, JsonUtil.class); + + /** + * Mapper. + */ + private static final ObjectMapper MAPPER = new ObjectMapper(); + + static { + MAPPER.setConfig(MAPPER.getDeserializationConfig().without( + DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)); + MAPPER.setSerializationInclusion(Include.NON_NULL); + } + + /** + * Constructor
+ *

+ *

+ * + * @since ONAP Amsterdam Release 2017-9-6 + */ + private JsonUtil() { + + } + + /** + * Parse the string in form of json.
+ * + * @param jsonstr json string. + * @param type that convert json string to + * @return model object + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static T unMarshal(String jsonstr, Class type) throws ApplicationException { + try { + return MAPPER.readValue(jsonstr, type); + } catch (IOException e) { + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, + "fail to unMarshal json", e); + throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json"); + } + } + + /** + * Parse the string in form of json.
+ * + * @param jsonstr json string. + * @param type that convert json string to + * @return model object + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static T unMarshal(String jsonstr, TypeReference type) throws ApplicationException { + try { + return MAPPER.readValue(jsonstr, type); + } catch (IOException e) { + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, + "fail to unMarshal json", e); + throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json"); + } + } + + /** + * Convert object to json string.
+ * + * @param srcObj data object + * @return json string + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static String marshal(Object srcObj) throws ApplicationException { + try { + return MAPPER.writeValueAsString(srcObj); + } catch (IOException e) { + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, + "fail to marshal json", e); + throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!"); + } + } + + /** + * Get mapper.
+ * + * @return mapper + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static ObjectMapper getMapper() { + return MAPPER; + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java new file mode 100644 index 0000000000..5b8779a67d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (C) 2017 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.vfc.util; + +import java.net.HttpURLConnection; +import java.net.SocketTimeoutException; + +import javax.ws.rs.core.UriBuilder; + +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +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.client.methods.HttpRequestBase; +import org.apache.http.conn.ConnectTimeoutException; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.onap.so.adapters.vfc.model.RestfulResponse; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoAlarmLogger; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +/** + *
+ *

+ *

+ * utility to invoke restclient + * + * @author + * @version ONAP Amsterdam Release 2017-9-6 + */ +@Component +public class RestfulUtil { + + /** + * Log service + */ + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, RestfulUtil.class); + + private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); + + private static final int DEFAULT_TIME_OUT = 60000; + + private static final String ONAP_IP = "ONAP_IP"; + + private static final String DEFAULT_MSB_IP = "127.0.0.1"; + + private static final Integer DEFAULT_MSB_PORT = 80; + + @Autowired + private Environment env; + + public String getMsbHost() { + // MSB_IP will be set as ONAP_IP environment parameter in install flow. + String msbIp = System.getenv().get(ONAP_IP); + // if ONAP IP is not set. get it from config file. + if(null == msbIp || msbIp.isEmpty()) { + msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP); + } + Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT); + + return UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString(); + } + + private RestfulUtil() { + + } + + public RestfulResponse send(String url, String methodType, String content) { + String msbUrl = getMsbHost() + url; + LOGGER.info(MessageEnum.RA_NS_EXC, "Begin to sent message " + methodType +": " + msbUrl, "org.onap.so.adapters.vfc.util.RestfulUtil","VFC Adapter"); + + HttpRequestBase method = null; + HttpResponse httpResponse = null; + + try { + int timeout = DEFAULT_TIME_OUT; + + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout).build(); + + HttpClient client = HttpClientBuilder.create().build(); + + if("POST".equalsIgnoreCase(methodType)) { + HttpPost httpPost = new HttpPost(msbUrl); + httpPost.setConfig(requestConfig); + httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); + method = httpPost; + } else if("PUT".equalsIgnoreCase(methodType)) { + HttpPut httpPut = new HttpPut(msbUrl); + httpPut.setConfig(requestConfig); + httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); + method = httpPut; + } else if("GET".equalsIgnoreCase(methodType)) { + HttpGet httpGet = new HttpGet(msbUrl); + httpGet.setConfig(requestConfig); + method = httpGet; + } else if("DELETE".equalsIgnoreCase(methodType)) { + HttpDelete httpDelete = new HttpDelete(msbUrl); + httpDelete.setConfig(requestConfig); + method = httpDelete; + } + + // now VFC have no auth + // String userCredentials = + // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, + // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); + // String authorization = "Basic " + + // DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + // method.setHeader("Authorization", authorization); + + httpResponse = client.execute(method); + + String responseContent = null; + if(httpResponse.getEntity() != null) { + responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); + } + + int statusCode = httpResponse.getStatusLine().getStatusCode(); + String statusMessage = httpResponse.getStatusLine().getReasonPhrase(); + + LOGGER.debug("VFC Response: " + statusCode + " " + statusMessage + + (responseContent == null ? "" : System.lineSeparator() + responseContent)); + + if(httpResponse.getStatusLine().getStatusCode() >= 300) { + String errMsg = "VFC returned " + statusCode + " " + statusMessage; + logError(errMsg); + return createResponse(statusCode, errMsg); + } + + httpResponse = null; + + if(null != method) { + method.reset(); + } else { + LOGGER.debug("method is NULL:"); + } + + method = null; + return createResponse(statusCode, responseContent); + + } catch(SocketTimeoutException | ConnectTimeoutException e) { + String errMsg = "Request to VFC timed out"; + logError(errMsg, e); + return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); + + } catch(Exception e) { + String errMsg = "Error processing request to VFC"; + logError(errMsg, e); + return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg); + + } finally { + if(httpResponse != null) { + try { + EntityUtils.consume(httpResponse.getEntity()); + } catch(Exception e) { + LOGGER.debug("Exception :", e); + } + } + + if(method != null) { + try { + method.reset(); + } catch(Exception e) { + LOGGER.debug("Exception :", e); + } + } + } + } + + private static void logError(String errMsg, Throwable t) { + LOGGER.error(MessageEnum.RA_NS_EXC, "VFC Adapter", "", MsoLogger.ErrorCode.AvailabilityError, errMsg, t); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + } + + private static void logError(String errMsg) { + LOGGER.error(MessageEnum.RA_NS_EXC, "VFC Adapter", "", MsoLogger.ErrorCode.AvailabilityError, errMsg); + ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); + } + + private static RestfulResponse createResponse(int statusCode, String content) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(statusCode); + rsp.setResponseContent(content); + return rsp; + } + +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java new file mode 100644 index 0000000000..d920dbea36 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/ValidateUtil.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.vfc.util; + +import org.onap.so.adapters.vfc.constant.HttpCode; +import org.onap.so.adapters.vfc.exceptions.ApplicationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ValidateUtil { + + /** + * Log server. + */ + private static final Logger LOGGER = LoggerFactory.getLogger(ValidateUtil.class); + + /** + * Constructor
+ *

+ *

+ * + * @since ONAP Amsterdam Release 2017-9-6 + */ + private ValidateUtil() { + + } + + /** + * Assert String parameter.
+ * + * @param paramValue parameter data + * @param paramName parameter name + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static void assertStringNotNull(String paramValue, String paramName) + throws ApplicationException { + if (null != paramValue && !paramValue.isEmpty()) { + return; + } + + LOGGER.error(paramName + ": Parameter is null or empty."); + throw new ApplicationException(HttpCode.BAD_REQUEST, paramName + ": Invalid parameter."); + } + + /** + * Assert object is null.
+ * + * @param object data object + * @since ONAP Amsterdam Release 2017-9-6 + */ + public static void assertObjectNotNull(Object object) throws ApplicationException { + if (null == object) { + LOGGER.error("Object is null."); + throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null."); + } + + } + + /** + *
+ * + * @param str + * @return + * @since ONAP Amsterdam Release + */ + public static boolean isStrEmpty(String str) { + return null == str || str.isEmpty(); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java deleted file mode 100644 index 7f1a6daae5..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/AaiUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc; - -import org.openecomp.mso.adapters.vfc.model.RestfulResponse; - -/** - * Implement class of operating aai database table
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ -public class AaiUtil { - - public static RestfulResponse addRelation(String globalSubsriberId, String serviceType, - String serviceInstanceId, String resourceInstanceId) { - // sent rest to aai to add relation for service and ns. - - return null; - } - - public static RestfulResponse removeRelation(String globalSubsriberId, String serviceType, - String serviceInstanceId, String resourceInstanceId) { - // sent rest to aai to remove relation between service an ns. - return null; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/HealthCheckHandler.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/HealthCheckHandler.java deleted file mode 100644 index 8e163d4d25..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/HealthCheckHandler.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc; - -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; - -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.HealthCheckUtils; -import org.openecomp.mso.utils.UUIDChecker; - -/** - * Health Check - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ -@Path("/") -public class HealthCheckHandler { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - - private static final String MSO_PROP_VFC_ADAPTER = "MSO_PROP_VFC_ADAPTER"; - - @HEAD - @GET - @Path("/healthcheck") - @Produces("text/html") - public Response healthcheck(@QueryParam("requestId") String requestId) { - long startTime = System.currentTimeMillis(); - MsoLogger.setServiceName("Healthcheck"); - UUIDChecker.verifyOldUUID(requestId, msoLogger); - HealthCheckUtils healthCheck = new HealthCheckUtils(); - if(!healthCheck.siteStatusCheck(msoLogger)) { - return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; - } - - if(!healthCheck.configFileCheck(msoLogger, startTime, MSO_PROP_VFC_ADAPTER)) { - return HealthCheckUtils.NOT_STARTED_RESPONSE; - } - - if(!healthCheck.catalogDBCheck(msoLogger, startTime)) { - return HealthCheckUtils.NOT_STARTED_RESPONSE; - } - msoLogger.debug("healthcheck - Successful"); - return HealthCheckUtils.HEALTH_CHECK_RESPONSE; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java deleted file mode 100644 index c1f19b7ffb..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException; -import org.openecomp.mso.adapters.vfc.model.NSResourceInputParameter; -import org.openecomp.mso.adapters.vfc.model.NsOperationKey; -import org.openecomp.mso.adapters.vfc.model.RestfulResponse; -import org.openecomp.mso.adapters.vfc.util.JsonUtil; -import org.openecomp.mso.adapters.vfc.util.ValidateUtil; -import org.openecomp.mso.logger.MsoLogger; - -/** - * The rest class for VF-c Adapter
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ -@Path("/v1/vfcadapter") -public class VfcAdapterRest { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - - private final VfcManager driverMgr = new VfcManager(); - - public VfcAdapterRest() { - - } - - /** - * Create a NS
- * - * @param data the http request - * @return - * @since ONAP Amsterdam Release - */ - @POST - @Path("/ns") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response createNfvoNs(String data) { - try { - ValidateUtil.assertObjectNotNull(data); - LOGGER.debug("body from request is {}" + data); - NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.createNs(nsInput); - return buildResponse(rsp); - } catch(ApplicationException e) { - LOGGER.debug("ApplicationException: ", e); - return e.buildErrorResponse(); - } - } - - /** - * Delete NS instance
- * - * @param servletReq http request - * @return response - * @since ONAP Amsterdam Release - */ - @DELETE - @Path("/ns/{nsInstanceId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response deleteNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { - try { - - ValidateUtil.assertObjectNotNull(data); - LOGGER.debug("body from request is {}" + data); - NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); - RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId); - return buildResponse(rsp); - } catch(ApplicationException e) { - LOGGER.debug("ApplicationException: ", e); - return e.buildErrorResponse(); - } - } - - /** - * Query Operation job status
- * - * @param servletReq The Http Request - * @param jobId The job id - * @return - * @since ONAP Amsterdam Release - */ - @POST - @Path("/jobs/{jobId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response queryNfvoJobStatus(String data, @PathParam("jobId") String jobId) { - try { - ValidateUtil.assertObjectNotNull(data); - LOGGER.debug("body from request is {}" + data); - NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); - RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId); - return buildResponse(rsp); - } catch(ApplicationException e) { - LOGGER.debug("ApplicationException: ", e); - return e.buildErrorResponse(); - } - } - - /** - * Instantiate NS instance
- * - * @param servletReq The http request - * @param nsInstanceId The NS instance id - * @return - * @since ONAP Amsterdam Release - */ - @POST - @Path("/ns/{nsInstanceId}/instantiate") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response instantiateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { - try { - ValidateUtil.assertObjectNotNull(data); - LOGGER.debug("body from request is {}" + data); - NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput); - return buildResponse(rsp); - } catch(ApplicationException e) { - LOGGER.debug("ApplicationException: ", e); - return e.buildErrorResponse(); - } - } - - /** - * Terminate NS instance
- * - * @param servletReq The http request - * @param nsInstanceId The NS instance id - * @return - * @since ONAP Amsterdam Release - */ - @POST - @Path("/ns/{nsInstanceId}/terminate") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response terminateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { - try { - ValidateUtil.assertObjectNotNull(data); - LOGGER.debug("body from request is {}" + data); - NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class); - RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId); - return buildResponse(rsp); - } catch(ApplicationException e) { - LOGGER.debug("ApplicationException: ", e); - return e.buildErrorResponse(); - } - } - - /** - * Scale NS instance - *
- * - * @param servletReq The http request - * @param nsInstanceId The NS instance id - * @return - * @since ONAP Amsterdam Release - */ - @POST - @Path("/ns/{nsInstanceId}/scale") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response scaleNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) { - try { - ValidateUtil.assertObjectNotNull(data); - LOGGER.debug("Scale Ns Request Received.Body from request is {}" + data); - NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class); - RestfulResponse rsp = driverMgr.scaleNs(nsInstanceId, nsInput); - return buildResponse(rsp); - } catch(ApplicationException e) { - LOGGER.debug("ApplicationException: ", e); - return e.buildErrorResponse(); - } - } - - - /** - * build response from restful response
- * - * @param rsp general response object - * @return - * @since ONAP Amsterdam Release - */ - private Response buildResponse(RestfulResponse rsp) { - return Response.status(rsp.getStatus()).entity(rsp.getResponseContent()).build(); - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java deleted file mode 100644 index 01e4c718d2..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java +++ /dev/null @@ -1,493 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc; - -import java.util.HashMap; -import java.util.Map; - -import org.openecomp.mso.adapters.vfc.constant.CommonConstant; -import org.openecomp.mso.adapters.vfc.constant.CommonConstant.Step; -import org.openecomp.mso.adapters.vfc.constant.DriverExceptionID; -import org.openecomp.mso.adapters.vfc.constant.HttpCode; -import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException; -import org.openecomp.mso.adapters.vfc.model.CustomerModel; -import org.openecomp.mso.adapters.vfc.model.NSResourceInputParameter; -import org.openecomp.mso.adapters.vfc.model.NsCreateReq; -import org.openecomp.mso.adapters.vfc.model.NsInstantiateReq; -import org.openecomp.mso.adapters.vfc.model.NsOperationKey; -import org.openecomp.mso.adapters.vfc.model.NsParameters; -import org.openecomp.mso.adapters.vfc.model.NsProgressStatus; -import org.openecomp.mso.adapters.vfc.model.ResponseDescriptor; -import org.openecomp.mso.adapters.vfc.model.RestfulResponse; -import org.openecomp.mso.adapters.vfc.model.*; -import org.openecomp.mso.adapters.vfc.util.JsonUtil; -import org.openecomp.mso.adapters.vfc.util.RestfulUtil; -import org.openecomp.mso.adapters.vfc.util.ValidateUtil; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.requestsdb.RequestsDbConstant; -import org.openecomp.mso.requestsdb.ResourceOperationStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * VF-C Manager
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ -public class VfcManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(VfcManager.class); - - /** - * nfvo url map - */ - private static Map nfvoUrlMap; - - static { - nfvoUrlMap = new HashMap<>(); - nfvoUrlMap.put(Step.CREATE, CommonConstant.NFVO_CREATE_URL); - nfvoUrlMap.put(Step.INSTANTIATE, CommonConstant.NFVO_INSTANTIATE_URL); - nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL); - nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL); - nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL); - nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL); - } - - public VfcManager() { - - } - - /** - * create network service
- * - * @param segInput input parameters for current node from http request - * @return - * @since ONAP Amsterdam Release - */ - public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException { - - // Step1: get service template by node type - String csarId = segInput.getNsServiceModelUUID(); - // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id" - LOGGER.info("serviceTemplateId is {}, id is {}", csarId); - - LOGGER.info("create ns -> begin"); - // Step2: Prepare url and method type - String url = getUrl(null, CommonConstant.Step.CREATE); - String methodType = CommonConstant.MethodType.POST; - - // Step3: Prepare restful parameters and options - NsCreateReq oRequest = new NsCreateReq(); - oRequest.setCsarId(csarId); - oRequest.setNsName(segInput.getNsServiceName()); - oRequest.setDescription(segInput.getNsServiceDescription()); - CustomerModel context = new CustomerModel(); - context.setGlobalCustomerId(segInput.getNsOperationKey().getGlobalSubscriberId()); - context.setServiceType(segInput.getNsOperationKey().getServiceType()); - oRequest.setContext(context); - String createReq = JsonUtil.marshal(oRequest); - - // Step4: Call NFVO or SDNO lcm to create ns - RestfulResponse createRsp = RestfulUtil.send(url, methodType, createReq); - ValidateUtil.assertObjectNotNull(createRsp); - LOGGER.info("create ns response status is : {}", createRsp.getStatus()); - LOGGER.info("create ns response content is : {}", createRsp.getResponseContent()); - - // Step 5: save resource operation information - ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()) - .getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), - segInput.getNsOperationKey().getOperationId(), - segInput.getNsOperationKey().getNodeTemplateUUID()); - nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING); - nsOperInfo.setProgress("40"); - nsOperInfo.setStatusDescription("NS is created"); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - - if (!HttpCode.isSucess(createRsp.getStatus())) { - LOGGER.error("update segment operation status : fail to create ns"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(createRsp.getStatus())); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.FAIL_TO_CREATE_NS); - } - @SuppressWarnings("unchecked") - Map rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class); - String nsInstanceId = rsp.get(CommonConstant.NS_INSTANCE_ID); - if (ValidateUtil.isStrEmpty(nsInstanceId)) { - LOGGER.error("Invalid instanceId from create operation"); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION); - } - LOGGER.info("create ns -> end"); - LOGGER.info("save segment and operaton info -> begin"); - // Step 6: add relation between service and NS - AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(), - segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(), - nsInstanceId); - LOGGER.info("save segment and operation info -> end"); - return createRsp; - } - - /** - * delete network service
- * - * @param nsOperationKey The operation key of the NS resource - * @param nsInstanceId The NS instance id - * @return - * @since ONAP Amsterdam Release - */ - public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) - throws ApplicationException { - LOGGER.info("delete ns -> begin"); - // Step1: prepare url and methodType - String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE); - String methodType = CommonConstant.MethodType.DELETE; - - // Step2: prepare restful parameters and options - RestfulResponse deleteRsp = RestfulUtil.send(url, methodType, ""); - ValidateUtil.assertObjectNotNull(deleteRsp); - LOGGER.info("delete ns response status is : {}", deleteRsp.getStatus()); - LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent()); - LOGGER.info("delete ns -> end"); - ResourceOperationStatus nsOperInfo = - (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(), - nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); - if (!HttpCode.isSucess(deleteRsp.getStatus())) { - LOGGER.error("fail to delete ns"); - - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(deleteRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.FAIL_TO_DELETE_NS); - } - - // Step3: remove relation info between service and ns - AaiUtil.removeRelation(nsOperationKey.getGlobalSubscriberId(), nsOperationKey.getServiceType(), - nsOperationKey.getServiceId(), nsInstanceId); - LOGGER.info("delete segment information -> end"); - - // Step4: update service segment operation status - nsOperInfo.setStatus(RequestsDbConstant.Status.FINISHED); - nsOperInfo.setErrorCode(String.valueOf(deleteRsp.getStatus())); - nsOperInfo.setProgress("100"); - nsOperInfo.setStatusDescription("VFC resource deletion finished"); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - LOGGER.info("update segment operaton status for delete -> end"); - - return deleteRsp; - - } - - /** - * instantiate network service
- * - * @param nsInstanceId The NS instance id - * @param segInput input parameters for current node from http request - * @return - * @since ONAP Amsterdam Release - */ - public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) - throws ApplicationException { - // Call the NFVO or SDNO service to instantiate service - LOGGER.info("instantiate ns -> begin"); - - // Step1: Prepare restful parameters and options - NsInstantiateReq oRequest = new NsInstantiateReq(); - oRequest.setNsInstanceId(nsInstanceId); - NsParameters nsParameters = segInput.getNsParameters(); - oRequest.setLocationConstraints(nsParameters.getLocationConstraints()); - oRequest.setAdditionalParamForNs(nsParameters.getAdditionalParamForNs()); - String instReq = JsonUtil.marshal(oRequest); - // Step2: prepare url and - String url = getUrl(nsInstanceId, CommonConstant.Step.INSTANTIATE); - String methodType = CommonConstant.MethodType.POST; - - RestfulResponse instRsp = RestfulUtil.send(url, methodType, instReq); - ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()) - .getResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), - segInput.getNsOperationKey().getOperationId(), - segInput.getNsOperationKey().getNodeTemplateUUID()); - ValidateUtil.assertObjectNotNull(instRsp); - if (!HttpCode.isSucess(instRsp.getStatus())) { - LOGGER.error("update segment operation status : fail to instantiate ns"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(instRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.FAIL_TO_INSTANTIATE_NS); - } - LOGGER.info("instantiate ns response status is : {}", instRsp.getStatus()); - LOGGER.info("instantiate ns response content is : {}", instRsp.getResponseContent()); - ValidateUtil.assertObjectNotNull(instRsp.getResponseContent()); - @SuppressWarnings("unchecked") - Map rsp = JsonUtil.unMarshal(instRsp.getResponseContent(), Map.class); - String jobId = rsp.get(CommonConstant.JOB_ID); - if (ValidateUtil.isStrEmpty(jobId)) { - LOGGER.error("Invalid jobId from instantiate operation"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(instRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.INSTANTIATE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION); - } - LOGGER.info("instantiate ns -> end"); - // Step 3: update segment operation job id - LOGGER.info("update resource operation status job id -> begin"); - nsOperInfo.setJobId(jobId); - nsOperInfo.setProgress("100"); - nsOperInfo.setStatusDescription("NS initiation completed."); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - LOGGER.info("update segment operation job id -> end"); - - return instRsp; - } - - /** - * terminate network service
- * - * @param nsOperationKey The operation key for NS resource - * @param nsInstanceId The NS instance id - * @return - * @since ONAP Amsterdam Release - */ - public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) - throws ApplicationException { - // Step1: save segment operation info for delete process - LOGGER.info("save segment operation for delete process"); - ResourceOperationStatus nsOperInfo = - (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(), - nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID()); - nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - - LOGGER.info("terminate ns -> begin"); - // Step2: prepare url and method type - String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE); - String methodType = CommonConstant.MethodType.POST; - - // Step3: prepare restful parameters and options - Map reqBody = new HashMap<>(); - reqBody.put("nsInstanceId", nsInstanceId); - reqBody.put("terminationType", "graceful"); - reqBody.put("gracefulTerminationTimeout", "60"); - - // Step4: Call the NFVO or SDNO service to terminate service - RestfulResponse terminateRsp = RestfulUtil.send(url, methodType, JsonUtil.marshal(reqBody)); - ValidateUtil.assertObjectNotNull(terminateRsp); - LOGGER.info("terminate ns response status is : {}", terminateRsp.getStatus()); - LOGGER.info("terminate ns response content is : {}", terminateRsp.getResponseContent()); - // Step 3: update segment operation - if (!HttpCode.isSucess(terminateRsp.getStatus())) { - LOGGER.error("fail to instantiate ns"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(terminateRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.FAIL_TO_TERMINATE_NS); - } - @SuppressWarnings("unchecked") - Map rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class); - String jobId = rsp.get(CommonConstant.JOB_ID); - if (ValidateUtil.isStrEmpty(jobId)) { - LOGGER.error("Invalid jobId from terminate operation"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(terminateRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.INVALID_RESPONSE_FROM_TERMINATE_OPERATION); - } - LOGGER.info("terminate ns -> end"); - - LOGGER.info("update segment job id -> begin"); - nsOperInfo.setProgress("60"); - nsOperInfo.setStatusDescription("NS is termination completed"); - nsOperInfo.setJobId(jobId); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - LOGGER.info("update segment job id -> end"); - - return terminateRsp; - } - - /** - * get ns progress by job Id
- * - * @param nsOperationKey The OperationKey for NS resource - * @param jobId the job id - * @return - * @since ONAP Amsterdam Release - */ - public RestfulResponse getNsProgress (NsOperationKey nsOperationKey, String jobId) throws ApplicationException { - - ValidateUtil.assertObjectNotNull (jobId); - // Step 1: query the current resource operation status - ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance ()).getResourceOperationStatus ( - nsOperationKey.getServiceId (), nsOperationKey.getOperationId (), nsOperationKey.getNodeTemplateUUID ()); - - // Step 2: start query - LOGGER.info ("query ns status -> begin"); - String url = getUrl (jobId, CommonConstant.Step.QUERY); - String methodType = CommonConstant.MethodType.GET; - // prepare restful parameters and options - RestfulResponse rsp = RestfulUtil.send (url, methodType, ""); - ValidateUtil.assertObjectNotNull (rsp); - LOGGER.info ("query ns progress response status is : {}", rsp.getStatus ()); - LOGGER.info ("query ns progress response content is : {}", rsp.getResponseContent ()); - // Step 3:check the response staus - if (!HttpCode.isSucess (rsp.getStatus ())) { - LOGGER.info ("fail to query job status"); - nsOperInfo.setErrorCode (String.valueOf (rsp.getStatus ())); - nsOperInfo.setStatus (RequestsDbConstant.Status.ERROR); - nsOperInfo.setStatusDescription (CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED); - (RequestsDatabase.getInstance ()).updateResOperStatus (nsOperInfo); - throw new ApplicationException (HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_QUERY_JOB_STATUS); - } - // Step 4: Process Network Service Instantiate Response - NsProgressStatus nsProgress = JsonUtil.unMarshal (rsp.getResponseContent (), NsProgressStatus.class); - ResponseDescriptor rspDesc = nsProgress.getResponseDescriptor (); - // Step 5: update segment operation progress - - nsOperInfo.setProgress (rspDesc.getProgress ()); - nsOperInfo.setStatusDescription (rspDesc.getStatusDescription ()); - (RequestsDatabase.getInstance ()).updateResOperStatus (nsOperInfo); - - // Step 6: update segment operation status - if (RequestsDbConstant.Progress.ONE_HUNDRED.equals (rspDesc.getProgress ()) - && RequestsDbConstant.Status.FINISHED.equals (rspDesc.getStatus ())) { - LOGGER.info ("job result is succeeded, operType is {}", nsOperInfo.getOperType ()); - nsOperInfo.setErrorCode (String.valueOf (rsp.getStatus ())); - String operType = nsOperInfo.getOperType (); - if (RequestsDbConstant.OperationType.CREATE.equalsIgnoreCase (operType) - || "createInstance".equalsIgnoreCase (operType)) { - nsOperInfo.setStatus (RequestsDbConstant.Status.FINISHED); - } - (RequestsDatabase.getInstance ()).updateResOperStatus (nsOperInfo); - } else if (RequestsDbConstant.Status.ERROR.equals (rspDesc.getStatus ())) { - LOGGER.error ("job result is failed, operType is {}", nsOperInfo.getOperType ()); - nsOperInfo.setErrorCode (String.valueOf (rsp.getStatus ())); - nsOperInfo.setStatusDescription (CommonConstant.StatusDesc.QUERY_JOB_STATUS_FAILED); - nsOperInfo.setStatus (RequestsDbConstant.Status.ERROR); - (RequestsDatabase.getInstance ()).updateResOperStatus (nsOperInfo); - throw new ApplicationException (HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.JOB_STATUS_ERROR); - } else { - LOGGER.error ("unexcepted response status"); - } - LOGGER.info ("query ns status -> end"); - - return rsp; - } - - /** - * Scale NS instance - *
- * - * @param nsInstanceId The NS instance id - * @param segInput input parameters for current node from http request - * @return - * @since ONAP Amsterdam Release - */ - public RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput) - throws ApplicationException { - // Call the NFVO to scale service - LOGGER.info("scale ns -> begin"); - - // Step1: Prepare restful parameters and options - VFCScaleData oRequest = new VFCScaleData(); - oRequest.setNsInstanceId(nsInstanceId); - NsScaleParameters nsScaleParameters = segInput.getNsScaleParameters(); - oRequest.setScaleType(nsScaleParameters.getScaleType()); - oRequest.setScaleNsData(nsScaleParameters.getScaleNsByStepsData()); - String scaleReq = JsonUtil.marshal(oRequest); - - // Step2: prepare url and method type - String url = getUrl(nsInstanceId, CommonConstant.Step.SCALE); - String methodType = CommonConstant.MethodType.POST; - LOGGER.info("scale ns request is {}", scaleReq); - // Step3: Call NFVO lcm to scale ns - RestfulResponse scaleRsp = RestfulUtil.send(url, methodType, scaleReq); - ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus( - segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), - segInput.getNsOperationKey().getNodeTemplateUUID()); - ValidateUtil.assertObjectNotNull(scaleRsp); - if(!HttpCode.isSucess(scaleRsp.getStatus())) { - LOGGER.error("update segment operation status : fail to scale ns"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_SCALE_NS); - } - LOGGER.info("scale ns response status is {}", scaleRsp.getStatus()); - LOGGER.info("scale ns response content is {}", scaleRsp.getResponseContent()); - - ValidateUtil.assertObjectNotNull(scaleRsp.getResponseContent()); - @SuppressWarnings("unchecked") - Map rsp = JsonUtil.unMarshal(scaleRsp.getResponseContent(), Map.class); - String jobId = rsp.get(CommonConstant.JOB_ID); - if(ValidateUtil.isStrEmpty(jobId)) { - LOGGER.error("Invalid jobId from scale operation"); - nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR); - nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus())); - nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, - DriverExceptionID.INVALID_RESPONSE_FROM_SCALE_OPERATION); - } - - LOGGER.info("update resource operation status job id -> begin"); - // Step 4: update segment operation job id - nsOperInfo.setJobId(jobId); - (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo); - LOGGER.info("update segment operation job id -> end"); - LOGGER.info("scale ns -> end"); - - return scaleRsp; - } - - /** - * get url for the operation
- * - * @param variable variable should be put in the url - * @param step step of the operation (terminate,query,delete) - * @return - * @since ONAP Amsterdam Release - */ - private String getUrl(String variable, String step) { - - String url; - String originalUrl; - originalUrl = (String) nfvoUrlMap.get(step); - url = String.format(originalUrl, variable); - return url; - - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java deleted file mode 100644 index 57c68def5a..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.constant; - -/** - * CommonConstant - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ -public class CommonConstant { - - public static final String STR_EMPTY = ""; - - public static final String NFVO_CREATE_URL = "/api/nslcm/v1/ns"; - - public static final String NFVO_INSTANTIATE_URL = "/api/nslcm/v1/ns/%s/instantiate"; - - public static final String NFVO_TERMINATE_URL = "/api/nslcm/v1/ns/%s/terminate"; - - public static final String NFVO_DELETE_URL = "/api/nslcm/v1/ns/%s"; - - public static final String NFVO_QUERY_URL = "/api/nslcm/v1/jobs/%s"; - - public static final String NFVO_SCALE_URL = "/api/nslcm/v1/ns/%s/scale"; - - /** - * - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ - public static class MethodType { - - public static final String POST = "post"; - - public static final String DELETE = "delete"; - - public static final String PUT = "put"; - - public static final String GET = "get"; - - private MethodType() { - - } - } - - /** - * - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-28 - */ - public static class Step { - - public static final String CREATE = "create"; - - public static final String INSTANTIATE = "instantiate"; - - public static final String STATUS = "status"; - - public static final String TERMINATE = "terminate"; - - public static final String QUERY = "query"; - - public static final String DELETE = "delete"; - - public static final String SCALE = "scale"; - - private Step() { - - } - - } - - - public static final String NSD_ID = "nsdId"; - - public static final String NS_NAME = "nsName"; - - public static final String DESC = "description"; - - public static final String NS_INSTANCE_ID = "nsInstanceId"; - - public static final String JOB_ID = "jobId"; - - public static final String ADDITIONAL_PARAM_FOR_NS = "additionalParamForNs"; - - public static final String LOCAL_HOST = "localhost"; - - public static class StatusDesc { - - public static final String INSTANTIATE_NS_FAILED = "instantiate ns failed"; - - public static final String QUERY_JOB_STATUS_FAILED = "query job status failed"; - - public static final String TERMINATE_NS_FAILED = "terminate ns failed"; - - public static final String DELETE_NS_FAILED = "delete ns failed"; - - public static final String CREATE_NS_FAILED = "create ns failed"; - - public static final String SCALE_NS_FAILED = "scale ns failed"; - - private StatusDesc() { - - } - } - - private CommonConstant() { - - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java deleted file mode 100644 index 48273f0c9f..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.constant; - -/** - *
- *

- *

- * identification of adapter exception - * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class DriverExceptionID { - - public static final String INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION = - "Invalid response from instantiate operation"; - - public static final String INVALID_RESPONSEE_FROM_CREATE_OPERATION = - "Invalid response from create operation"; - - public static final String FAIL_TO_INSTANTIATE_NS = "Fail to instantiate ns"; - - public static final String FAIL_TO_CREATE_NS = "Fail to create ns"; - - public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION = - "Invalid response from terminate operation"; - - public static final String FAIL_TO_DELETE_NS = "Fail to delete ns"; - - public static final String FAIL_TO_TERMINATE_NS = "Fail to terminate ns"; - - public static final String JOB_STATUS_ERROR = "Job status error"; - - public static final String FAIL_TO_QUERY_JOB_STATUS = "Fail to query job status"; - - public static final String FAIL_TO_SCALE_NS = "Fail to scale network service"; - - public static final String INVALID_RESPONSE_FROM_SCALE_OPERATION = "Invalid response from scale operation"; - - - private DriverExceptionID() { - - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/HttpCode.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/HttpCode.java deleted file mode 100644 index 0eda7bd33b..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/HttpCode.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.constant; - -/** - * Constant Class.
- *

- * Define constant for http operation. - *

- * - * @author - * @version ONAP Amsterdam 2016/8/4 - */ -public class HttpCode { - - /** - * Fail to request. - */ - public static final int BAD_REQUEST = 400; - - /** - * Inner error - */ - public static final int INTERNAL_SERVER_ERROR = 500; - - /** - * Not accept request. - */ - public static final int NOT_ACCEPTABLE = 406; - - /** - * Not found service. - */ - public static final int NOT_FOUND = 404; - - /** - * Accept request. - */ - public static final int RESPOND_ACCEPTED = 202; - - /** - * Http response is ok. - */ - public static final int RESPOND_OK = 200; - - public static final int CREATED_OK = 201; - - /** - * Conflict - */ - public static final int RESPOND_CONFLICT = 409; - - /** - * Constructor
- *

- *

- * - * @since ONAP Amsterdam Release 2017-9-6 - */ - private HttpCode() { - - } - - /** - * Whether request is successful.
- * - * @param httpCode response code - * @return true or false - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static boolean isSucess(int httpCode) { - return httpCode / 100 == 2; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java deleted file mode 100644 index 039c1604ba..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.exceptions; - -import javax.ws.rs.core.Response; - -public class ApplicationException extends Exception { - - /** - * Serial number. - */ - private static final long serialVersionUID = 1L; - - private int errorCode; - - private String errorMsg; - - /** - * Constructor
- *

- *

- * - * @param errorCode error status - * @param errorMsg error detail - * @since ONAP Amsterdam Release 2017-9-6 - */ - 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; - } - - /** - * build error Response - *
- * - * @return - * @since ONAP Amsterdam Release - */ - public Response buildErrorResponse() { - return Response.status(errorCode).entity(errorMsg).build(); - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/CustomerModel.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/CustomerModel.java deleted file mode 100644 index fa0347bf48..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/CustomerModel.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -/** - * The Customer Model - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-10-12 - */ -public class CustomerModel { - - String globalCustomerId; - - String serviceType; - - - /** - * @return Returns the globalCustomerId. - */ - public String getGlobalCustomerId() { - return globalCustomerId; - } - - - /** - * @param globalCustomerId The globalCustomerId to set. - */ - public void setGlobalCustomerId(String globalCustomerId) { - this.globalCustomerId = globalCustomerId; - } - - - /** - * @return Returns the serviceType. - */ - public String getServiceType() { - return serviceType; - } - - - /** - * @param serviceType The serviceType to set. - */ - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java deleted file mode 100644 index 214451b22f..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/LocationConstraint.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -/** - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class LocationConstraint { - - /** - * vnf profile id - */ - private String vnfProfileId; - - /** - * location constraints: vimId - */ - private VimLocation locationConstraints; - - /** - * @return Returns the vnfProfileId. - */ - public String getVnfProfileId() { - return vnfProfileId; - } - - /** - * @param vnfProfileId The vnfProfileId to set. - */ - public void setVnfProfileId(String vnfProfileId) { - this.vnfProfileId = vnfProfileId; - } - - - /** - * @return Returns the locationConstraints. - */ - public VimLocation getLocationConstraints() { - return locationConstraints; - } - - - /** - * @param locationConstraints The locationConstraints to set. - */ - public void setLocationConstraints(VimLocation locationConstraints) { - this.locationConstraints = locationConstraints; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java deleted file mode 100644 index d46844364f..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (C) 2018 CMCC 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.openecomp.mso.adapters.vfc.model; - -import java.io.ByteArrayOutputStream; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.openecomp.mso.logger.MsoLogger; - -/** - * NS Create Input Parameter For VFC Adapter
- *

- *

- * - * @version ONAP Amsterdam Release 2017/1/7 - */ -public class NSResourceInputParameter { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - - private NsOperationKey nsOperationKey; - - private String nsServiceName; - - private String nsServiceDescription; - - private String nsServiceModelUUID; - - private NsParameters nsParameters; - - private NsScaleParameters nsScaleParameters; - - - /** - * @return Returns the nsServiceName. - */ - public String getNsServiceName() { - return nsServiceName; - } - - - /** - * @param nsServiceName The nsServiceName to set. - */ - public void setNsServiceName(String nsServiceName) { - this.nsServiceName = nsServiceName; - } - - - /** - * @return Returns the nsServiceDescription. - */ - public String getNsServiceDescription() { - return nsServiceDescription; - } - - - /** - * @param nsServiceDescription The nsServiceDescription to set. - */ - public void setNsServiceDescription(String nsServiceDescription) { - this.nsServiceDescription = nsServiceDescription; - } - - /** - * @return Returns the nsParameters. - */ - public NsParameters getNsParameters() { - return nsParameters; - } - - /** - * @param nsParameters The nsParameters to set. - */ - public void setNsParameters(NsParameters nsParameters) { - this.nsParameters = nsParameters; - } - - public NsOperationKey getNsOperationKey() { - return nsOperationKey; - } - - public void setNsOperationKey(NsOperationKey nsOperationKey) { - this.nsOperationKey = nsOperationKey; - } - public String toJsonString() { - String jsonString = null; - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); - jsonString = mapper.writeValueAsString(this); - } catch (Exception e) { - LOGGER.debug("Exception:", e); - } - return jsonString; - } - - public String toXmlString() { - try { - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - JAXBContext context = JAXBContext.newInstance(this.getClass()); - Marshaller marshaller = context.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML - marshaller.marshal(this, bs); - return bs.toString(); - } catch (Exception e) { - LOGGER.debug("Exception:", e); - return ""; - } - } - - public NsScaleParameters getNsScaleParameters() { - return nsScaleParameters; - } - - public void setNsScaleParameters(NsScaleParameters nsScaleParameters) { - this.nsScaleParameters = nsScaleParameters; - } - - - public String getNsServiceModelUUID() { - return nsServiceModelUUID; - } - - - public void setNsServiceModelUUID(String nsServiceModelUUID) { - this.nsServiceModelUUID = nsServiceModelUUID; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsCreateReq.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsCreateReq.java deleted file mode 100644 index 3887624be0..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsCreateReq.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -/** - * Network Service Request
- *

- *

- * - * @author - * @version ONAP Amsterdam Sep 2, 2016 - */ -public class NsCreateReq { - - CustomerModel context; - - String csarId; - - String nsName; - - String description; - - - /** - * @return Returns the context. - */ - public CustomerModel getContext() { - return context; - } - - - - /** - * @param context The context to set. - */ - public void setContext(CustomerModel context) { - this.context = context; - } - - - /** - * @return Returns the csarId. - */ - public String getCsarId() { - return csarId; - } - - - /** - * @param csarId The csarId to set. - */ - public void setCsarId(String csarId) { - this.csarId = csarId; - } - - /** - * @return Returns the nsName. - */ - public String getNsName() { - return nsName; - } - - /** - * @param nsName The nsName to set. - */ - public void setNsName(String nsName) { - this.nsName = nsName; - } - - /** - * @return Returns the description. - */ - public String getDescription() { - return description; - } - - /** - * @param description The description to set. - */ - public void setDescription(String description) { - this.description = description; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReq.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReq.java deleted file mode 100644 index 7e8a9ce0c3..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReq.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -/** - *
- *

- *

- * request model for instatiate - * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class NsInstantiateReq extends NsParameters { - - String nsInstanceId; - - /** - * @return Returns the nsInstanceId. - */ - public String getNsInstanceId() { - return nsInstanceId; - } - - /** - * @param nsInstanceId The nsInstanceId to set. - */ - public void setNsInstanceId(String nsInstanceId) { - this.nsInstanceId = nsInstanceId; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java deleted file mode 100644 index 23bf36fe0c..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -/** - * The operation key object for NS - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-09-15 - */ -public class NsOperationKey { - - /** - * The subscriber id - */ - private String globalSubscriberId; - - /** - * The serviceType - */ - private String serviceType; - - /** - * The service ID - */ - private String serviceId; - - /** - * The Operation ID - */ - private String operationId; - - /** - * the NS template uuid - */ - private String nodeTemplateUUID; - - /** - * @return Returns the globalSubscriberId. - */ - public String getGlobalSubscriberId() { - return globalSubscriberId; - } - - /** - * @param globalSubscriberId The globalSubscriberId to set. - */ - public void setGlobalSubscriberId(String globalSubscriberId) { - this.globalSubscriberId = globalSubscriberId; - } - - /** - * @return Returns the serviceType. - */ - public String getServiceType() { - return serviceType; - } - - /** - * @param serviceType The serviceType to set. - */ - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - /** - *
- * - * @return - * @since ONAP Amsterdam Release - */ - public String getServiceId() { - return serviceId; - } - - /** - *
- * - * @param serviceId - * @since ONAP Amsterdam Release - */ - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - /** - *
- * - * @return - * @since ONAP Amsterdam Release - */ - public String getOperationId() { - return operationId; - } - - /** - *
- * - * @param operationId - * @since ONAP Amsterdam Release - */ - public void setOperationId(String operationId) { - this.operationId = operationId; - } - - /** - * @return Returns the nodeTemplateUUID. - */ - public String getNodeTemplateUUID() { - return nodeTemplateUUID; - } - - /** - * @param nodeTemplateUUID The nodeTemplateUUID to set. - */ - public void setNodeTemplateUUID(String nodeTemplateUUID) { - this.nodeTemplateUUID = nodeTemplateUUID; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java deleted file mode 100644 index b4827d0f45..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsParameters.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class NsParameters { - - private List locationConstraints; - - private Map additionalParamForNs = new HashMap<>(); - /** - * @return Returns the locationConstraints. - */ - public List getLocationConstraints() { - return locationConstraints; - } - - /** - * @param locationConstraints The locationConstraints to set. - */ - public void setLocationConstraints(List locationConstraints) { - this.locationConstraints = locationConstraints; - } - - - /** - * @return Returns the additionalParamForNs. - */ - public Map getAdditionalParamForNs() { - return additionalParamForNs; - } - - - /** - * @param additionalParamForNs The additionalParamForNs to set. - */ - public void setAdditionalParamForNs(Map additionalParamForNs) { - this.additionalParamForNs = additionalParamForNs; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatus.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatus.java deleted file mode 100644 index d68da47ed7..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatus.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -import java.util.List; - -/** - *
- *

- *

- * response model of query operation status - * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class NsProgressStatus { - - String jobId; - - ResponseDescriptor responseDescriptor; - - List responseHistoryList; - - /** - * @return Returns the jobId. - */ - public String getJobId() { - return jobId; - } - - /** - * @param jobId The jobId to set. - */ - public void setJobId(String jobId) { - this.jobId = jobId; - } - - /** - * @return Returns the responseDescriptor. - */ - public ResponseDescriptor getResponseDescriptor() { - return responseDescriptor; - } - - /** - * @param responseDescriptor The responseDescriptor to set. - */ - public void setResponseDescriptor(ResponseDescriptor responseDescriptor) { - this.responseDescriptor = responseDescriptor; - } - - /** - * @return Returns the responseHistoryList. - */ - public List getResponseHistoryList() { - return responseHistoryList; - } - - /** - * @param responseHistoryList The responseHistoryList to set. - */ - public void setResponseHistoryList(List responseHistoryList) { - this.responseHistoryList = responseHistoryList; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java deleted file mode 100644 index eb40cddc7b..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 CMCC 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.openecomp.mso.adapters.vfc.model; - -import java.util.List; - -/** - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-9-26 - */ -public class NsScaleParameters { - - private List scaleNsByStepsData; - - private String scaleType; - - /** - * @return Returns the scaleNsByStepsData. - */ - public List getScaleNsByStepsData() { - return scaleNsByStepsData; - } - - /** - * @param scaleNsByStepsData The scaleNsByStepsData to set. - */ - public void setScaleNsByStepsData(List scaleNsByStepsData) { - this.scaleNsByStepsData = scaleNsByStepsData; - } - - /** - * @return Returns the scale Type. - */ - public String getScaleType() { - return scaleType; - } - - /** - * @param scaleType The scaleType to set. - */ - public void setScaleType(String scaleType) { - this.scaleType = scaleType; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java deleted file mode 100644 index 1d9e7aabac..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 CMCC 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.openecomp.mso.adapters.vfc.model; - -/** - *
- *

- *

- * request model for scale - * - * @author - * @version ONAP Amsterdam Release 2017-9-26 - */ -public class NsScaleReq extends NsScaleParameters { - - String nsInstanceId; - - /** - * @return Returns the nsInstanceId. - */ - public String getNsInstanceId() { - return nsInstanceId; - } - - /** - * @param nsInstanceId The nsInstanceId to set. - */ - public void setNsInstanceId(String nsInstanceId) { - this.nsInstanceId = nsInstanceId; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptor.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptor.java deleted file mode 100644 index 6c40c0df32..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptor.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; -/** - *
- *

- *

- * response model of query operation status - * - * @author - * @version SDNO 0.5 September 3, 2016 - */ -public class ResponseDescriptor { - - String status; - - String progress; - - String statusDescription; - - Integer errorCode; - - Integer responseId; - - /** - * @return Returns the status. - */ - public String getStatus() { - return status; - } - - /** - * @param status The status to set. - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * @return Returns the progress. - */ - public String getProgress() { - return progress; - } - - /** - * @param progress The progress to set. - */ - public void setProgress(String progress) { - this.progress = progress; - } - - /** - * @return Returns the statusDescription. - */ - public String getStatusDescription() { - return statusDescription; - } - - /** - * @param statusDescription The statusDescription to set. - */ - public void setStatusDescription(String statusDescription) { - this.statusDescription = statusDescription; - } - - /** - * @return Returns the errorCode. - */ - public Integer getErrorCode() { - return errorCode; - } - - /** - * @param errorCode The errorCode to set. - */ - public void setErrorCode(Integer errorCode) { - this.errorCode = errorCode; - } - - /** - * @return Returns the responseId. - */ - public Integer getResponseId() { - return responseId; - } - - /** - * @param responseId The responseId to set. - */ - public void setResponseId(Integer responseId) { - this.responseId = responseId; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/RestfulResponse.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/RestfulResponse.java deleted file mode 100644 index e4f7f306b2..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/RestfulResponse.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -import java.util.Map; - -/** - * The Unified Restful Reponse Class - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-09-06 - */ -public class RestfulResponse { - - // the response content - private String responseContent; - - //the response status - private int status; - - //the response header - private Map respHeaderMap; - - public RestfulResponse() { - this.status = -1; - - this.respHeaderMap = null; - } - - public int getStatus() { - return this.status; - } - - public void setStatus(int status) { - this.status = status; - } - - public Map getRespHeaderMap() { - return this.respHeaderMap; - } - - public void setRespHeaderMap(Map header) { - this.respHeaderMap = header; - } - - public int getRespHeaderInt(String key) { - if(this.respHeaderMap != null) { - String result = this.respHeaderMap.get(key); - if(result != null) { - return Integer.parseInt(result); - } - } - return -1; - } - - public long getRespHeaderLong(String key) { - if(this.respHeaderMap != null) { - String result = this.respHeaderMap.get(key); - if(result != null) { - return Long.parseLong(result); - } - } - return -1L; - } - - public String getRespHeaderStr(String key) { - if(this.respHeaderMap != null) { - return this.respHeaderMap.get(key); - } - return null; - } - - public String getResponseContent() { - return this.responseContent; - } - - public void setResponseContent(String responseString) { - this.responseContent = responseString; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java deleted file mode 100644 index 668b66013d..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 CMCC 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.openecomp.mso.adapters.vfc.model; - -/** - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-9-26 - */ -public class ScaleNsByStepsData { - - /** - * scaling Direction - */ - private String scalingDirection; - - /** - * aspect ID - */ - private String aspectId; - - /** - * number of Steps - */ - private Integer numberOfSteps; - - /** - * @return Returns the scalingDirection. - */ - public String getScalingDirection() { - return scalingDirection; - } - - /** - * @param scalingDirection The scalingDirection to set. - */ - public void setScalingDirection(String scalingDirection) { - this.scalingDirection = scalingDirection; - } - - /** - * @return Returns the aspectId. - */ - public String getAspectId() { - return aspectId; - } - - /** - * @param aspectId The aspectId to set. - */ - public void setAspectId(String aspectId) { - this.aspectId = aspectId; - } - - /** - * @return Returns the numberOfSteps. - */ - public Integer getNumberOfSteps() { - return numberOfSteps; - } - - /** - * @param numberOfSteps The numberOfSteps to set. - */ - public void setNumberOfSteps(int numberOfSteps) { - this.numberOfSteps = numberOfSteps; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java deleted file mode 100644 index 437af5be11..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 CMCC 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.openecomp.mso.adapters.vfc.model; - -import java.util.List; - -/** - * aim to wrap List as a new list - * then be provided for the usage of vfc json - * - * added on 2018/01/30 by Qihui Zhao from CMCC - * */ - -public class ScaleNsData { - - private List scaleNsByStepsData; - - /** - * @return Returns the scaleNsByStepsData. - */ - public List getScaleNsByStepsData() { - return scaleNsByStepsData; - } - - /** - * @param scaleNsByStepsData The scaleNsByStepsData to set. - */ - public void setScaleNsByStepsData(List scaleNsByStepsData) { - this.scaleNsByStepsData = scaleNsByStepsData; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java deleted file mode 100644 index 33460b4757..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 CMCC 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.openecomp.mso.adapters.vfc.model; - -import java.util.ArrayList; -import java.util.List; - -/** - * Object totally matches required VFC input json format - * JsonUtil.marshal will convert this Object to string - * - * added on 2018/01/30 by Qihui Zhao from CMCC*/ - -public class VFCScaleData { - - private String nsInstanceId; - - private String scaleType; - - private List scaleNsData = new ArrayList<>(); - - /** - * @return Returns the nsInstanceId. - */ - public String getNsInstanceId() { - return nsInstanceId; - } - - /** - * @param nsInstanceId The nsInstanceId to set. - */ - public void setNsInstanceId(String nsInstanceId) { - this.nsInstanceId = nsInstanceId; - } - - /** - * @return Returns the scale Type. - */ - public String getScaleType() { - return scaleType; - } - - /** - * @param scaleType The scaleType to set. - */ - public void setScaleType(String scaleType) { - this.scaleType = scaleType; - } - - /** - *@return Returns the scaleNsDate. - */ - public List getScaleNsData(){return scaleNsData;} - - /** - * The scaleNsData to set. - */ - public void setScaleNsData(List scaleNsByStepsData){ - ScaleNsData scaleNsDataObj = new ScaleNsData(); - scaleNsDataObj.setScaleNsByStepsData(scaleNsByStepsData); - - this.scaleNsData.add(scaleNsDataObj); - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java deleted file mode 100644 index 3c07f9cd8b..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VimLocation.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.model; - -/** - * - *
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-10-18 - */ -public class VimLocation { - private String vimId; - - - /** - * @return Returns the vimId. - */ - public String getVimId() { - return vimId; - } - - - /** - * @param vimId The vimId to set. - */ - public void setVimId(String vimId) { - this.vimId = vimId; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java deleted file mode 100644 index d270230ba9..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.util; - -import java.io.IOException; - -import org.openecomp.mso.adapters.vfc.constant.HttpCode; -import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Interface for json analyzing.
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class JsonUtil { - - /** - * Log service - */ - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - - /** - * Mapper. - */ - private static final ObjectMapper MAPPER = new ObjectMapper(); - - static { - MAPPER.setConfig(MAPPER.getDeserializationConfig().without( - DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)); - MAPPER.setSerializationInclusion(Include.NON_NULL); - } - - /** - * Constructor
- *

- *

- * - * @since ONAP Amsterdam Release 2017-9-6 - */ - private JsonUtil() { - - } - - /** - * Parse the string in form of json.
- * - * @param jsonstr json string. - * @param type that convert json string to - * @return model object - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static T unMarshal(String jsonstr, Class type) throws ApplicationException { - try { - return MAPPER.readValue(jsonstr, type); - } catch (IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, - "fail to unMarshal json", e); - throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json"); - } - } - - /** - * Parse the string in form of json.
- * - * @param jsonstr json string. - * @param type that convert json string to - * @return model object - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static T unMarshal(String jsonstr, TypeReference type) throws ApplicationException { - try { - return MAPPER.readValue(jsonstr, type); - } catch (IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, - "fail to unMarshal json", e); - throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json"); - } - } - - /** - * Convert object to json string.
- * - * @param srcObj data object - * @return json string - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static String marshal(Object srcObj) throws ApplicationException { - try { - return MAPPER.writeValueAsString(srcObj); - } catch (IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, - "fail to marshal json", e); - throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!"); - } - } - - /** - * Get mapper.
- * - * @return mapper - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static ObjectMapper getMapper() { - return MAPPER; - } -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java deleted file mode 100644 index 9b00e4e1eb..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/RestfulUtil.java +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.util; - -import java.net.HttpURLConnection; -import java.net.SocketTimeoutException; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -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.client.methods.HttpRequestBase; -import org.apache.http.conn.ConnectTimeoutException; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.openecomp.mso.adapters.vfc.model.RestfulResponse; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - *
- *

- *

- * utility to invoke restclient - * - * @author - * @version ONAP Amsterdam Release 2017-9-6 - */ -public class RestfulUtil { - - /** - * Log service - */ - private static final Logger LOGGER = LoggerFactory.getLogger(RestfulUtil.class); - - private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger(); - - private static final int DEFAULT_TIME_OUT = 60000; - - private static final String ONAP_IP = "ONAP_IP"; - - private static final String DEFAULT_MSB_IP = "127.0.0.1"; - - private static final String DEFAULT_MSB_PORT = "80"; - - private static final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - public static String getMsbHost() { - String msbPort = DEFAULT_MSB_PORT; - // MSB_IP will be set as ONAP_IP environment parameter in install flow. - String msbIp = System.getenv().get(ONAP_IP); - try { - // if ONAP IP is not set. get it from config file. - if(null == msbIp || msbIp.isEmpty()) { - msbIp = msoPropertiesFactory.getMsoJavaProperties("MSO_PROP_TOPOLOGY").getProperty("msb-ip", DEFAULT_MSB_IP); - msbPort = msoPropertiesFactory.getMsoJavaProperties("MSO_PROP_TOPOLOGY").getProperty("msb-port", DEFAULT_MSB_PORT); - } - } catch(MsoPropertiesException e) { - LOGGER.error("Get msb properties failed",e); - } - return "http://" + msbIp + ":" + msbPort; - } - - private RestfulUtil() { - - } - - public static RestfulResponse send(String url, String methodType, String content) { - String msbUrl = getMsbHost() + url; - LOGGER.info("Begin to sent message " + methodType +": " + msbUrl); - - HttpRequestBase method = null; - HttpResponse httpResponse = null; - - try { - int timeout = DEFAULT_TIME_OUT; - - RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) - .setConnectionRequestTimeout(timeout).build(); - - HttpClient client = HttpClientBuilder.create().build(); - - if("POST".equalsIgnoreCase(methodType)) { - HttpPost httpPost = new HttpPost(msbUrl); - httpPost.setConfig(requestConfig); - httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); - method = httpPost; - } else if("PUT".equalsIgnoreCase(methodType)) { - HttpPut httpPut = new HttpPut(msbUrl); - httpPut.setConfig(requestConfig); - httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); - method = httpPut; - } else if("GET".equalsIgnoreCase(methodType)) { - HttpGet httpGet = new HttpGet(msbUrl); - httpGet.setConfig(requestConfig); - method = httpGet; - } else if("DELETE".equalsIgnoreCase(methodType)) { - HttpDelete httpDelete = new HttpDelete(msbUrl); - httpDelete.setConfig(requestConfig); - method = httpDelete; - } - - // now VFC have no auth - // String userCredentials = - // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, - // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); - // String authorization = "Basic " + - // DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - // method.setHeader("Authorization", authorization); - - httpResponse = client.execute(method); - - String responseContent = null; - if(httpResponse.getEntity() != null) { - responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); - } - - int statusCode = httpResponse.getStatusLine().getStatusCode(); - String statusMessage = httpResponse.getStatusLine().getReasonPhrase(); - - LOGGER.debug("VFC Response: " + statusCode + " " + statusMessage - + (responseContent == null ? "" : System.lineSeparator() + responseContent)); - - if(httpResponse.getStatusLine().getStatusCode() >= 300) { - String errMsg = "VFC returned " + statusCode + " " + statusMessage; - logError(errMsg); - return createResponse(statusCode, errMsg); - } - - httpResponse = null; - - if(null != method) { - method.reset(); - } else { - LOGGER.debug("method is NULL:"); - } - - method = null; - return createResponse(statusCode, responseContent); - - } catch(SocketTimeoutException | ConnectTimeoutException e) { - String errMsg = "Request to VFC timed out"; - logError(errMsg, e); - return createResponse(HttpURLConnection.HTTP_CLIENT_TIMEOUT, errMsg); - - } catch(Exception e) { - String errMsg = "Error processing request to VFC"; - logError(errMsg, e); - return createResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, errMsg); - - } finally { - if(httpResponse != null) { - try { - EntityUtils.consume(httpResponse.getEntity()); - } catch(Exception e) { - LOGGER.debug("Exception :", e); - } - } - - if(method != null) { - try { - method.reset(); - } catch(Exception e) { - LOGGER.debug("Exception :", e); - } - } - } - } - - private static void logError(String errMsg, Throwable t) { - LOGGER.error(errMsg, t); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); - } - - private static void logError(String errMsg) { - LOGGER.error(errMsg); - ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, errMsg); - } - - private static RestfulResponse createResponse(int statusCode, String content) { - RestfulResponse rsp = new RestfulResponse(); - rsp.setStatus(statusCode); - rsp.setResponseContent(content); - return rsp; - } - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java deleted file mode 100644 index 8bfa93351b..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc.util; - -import org.openecomp.mso.adapters.vfc.constant.HttpCode; -import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ValidateUtil { - - /** - * Log server. - */ - private static final Logger LOGGER = LoggerFactory.getLogger(ValidateUtil.class); - - /** - * Constructor
- *

- *

- * - * @since ONAP Amsterdam Release 2017-9-6 - */ - private ValidateUtil() { - - } - - /** - * Assert String parameter.
- * - * @param paramValue parameter data - * @param paramName parameter name - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static void assertStringNotNull(String paramValue, String paramName) - throws ApplicationException { - if (null != paramValue && !paramValue.isEmpty()) { - return; - } - - LOGGER.error(paramName + ": Parameter is null or empty."); - throw new ApplicationException(HttpCode.BAD_REQUEST, paramName + ": Invalid parameter."); - } - - /** - * Assert object is null.
- * - * @param object data object - * @since ONAP Amsterdam Release 2017-9-6 - */ - public static void assertObjectNotNull(Object object) throws ApplicationException { - if (null == object) { - LOGGER.error("Object is null."); - throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null."); - } - - } - - /** - *
- * - * @param str - * @return - * @since ONAP Amsterdam Release - */ - public static boolean isStrEmpty(String str) { - return null == str || str.isEmpty(); - } -} diff --git a/adapters/mso-vfc-adapter/src/main/resources/application.yaml b/adapters/mso-vfc-adapter/src/main/resources/application.yaml new file mode 100644 index 0000000000..ba574ba3e9 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/resources/application.yaml @@ -0,0 +1,37 @@ +logging: + path: logs + +# H2 +spring: + datasource: + url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1; + username: sa + password: sa + driver-class-name: org.h2.Driver + intialize: true + h2: + console: + enabled: true + path: /h2 + +server: + port: 8080 + tomcat: + max-threads: 50 +mso: + site-name: localSite + +#Actuator +management: + security: + enabled: false + basic: + enabled: false + 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. + + diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java new file mode 100644 index 0000000000..ec3741dc1a --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/exceptions/ApplicationExceptionTest.java @@ -0,0 +1,42 @@ +/* +* ============LICENSE_START======================================================= + * ONAP : SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * 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.vfc.exceptions; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ApplicationExceptionTest { + private ApplicationException application = new ApplicationException(0,null); + + @Test + public void testApplicationException() { + application.setErrorCode(0); + application.setErrorMsg("ErrorMsg"); + assertEquals(application.getErrorCode(), 0); + assertEquals(application.getErrorMsg(), "ErrorMsg"); + } + + @Test + public void testbuildErrorResponse(){ + assert(application.buildErrorResponse()!=null); + } +} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java new file mode 100644 index 0000000000..2acd6c25ad --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/CustomerModelTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class CustomerModelTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + CustomerModel customerModel = new CustomerModel(); + + @Test + public void getGlobalCustomerId() throws Exception { + customerModel.getGlobalCustomerId(); + } + + @Test + public void setGlobalCustomerId() throws Exception { + customerModel.setGlobalCustomerId("test"); + } + + @Test + public void getServiceType() throws Exception { + customerModel.getServiceType(); + } + + @Test + public void setServiceType() throws Exception { + customerModel.setServiceType("service"); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java new file mode 100644 index 0000000000..ef5eb2617e --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/LocationConstraintTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class LocationConstraintTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + LocationConstraint locationConstraint = new LocationConstraint(); + + @Test + public void getVnfProfileId() throws Exception { + locationConstraint.getVnfProfileId(); + } + + @Test + public void setVnfProfileId() throws Exception { + locationConstraint.setVnfProfileId("profileID"); + } + + @Test + public void getLocationConstraints() throws Exception { + locationConstraint.getLocationConstraints(); + } + + @Test + public void setLocationConstraints() throws Exception { + locationConstraint.setLocationConstraints(new VimLocation()); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java new file mode 100644 index 0000000000..2e720e47ad --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NSResourceInputParameterTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class NSResourceInputParameterTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter(); + + @Test + public void getNsServiceName() throws Exception { + nsResourceInputParameter.getNsServiceName(); + } + + @Test + public void setNsServiceName() throws Exception { + nsResourceInputParameter.setNsServiceName("service"); + } + + @Test + public void getNsServiceDescription() throws Exception { + nsResourceInputParameter.getNsServiceDescription(); + } + + @Test + public void setNsServiceDescription() throws Exception { + nsResourceInputParameter.setNsServiceDescription("desc"); + } + + @Test + public void getNsParameters() throws Exception { + nsResourceInputParameter.getNsParameters(); + } + + @Test + public void setNsParameters() throws Exception { + nsResourceInputParameter.setNsParameters(new NsParameters()); + } + + @Test + public void getNsOperationKey() throws Exception { + nsResourceInputParameter.getNsOperationKey(); + } + + @Test + public void setNsOperationKey() throws Exception { + nsResourceInputParameter.setNsOperationKey(new NsOperationKey()); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java new file mode 100644 index 0000000000..caf2d7e164 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsCreateReqTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class NsCreateReqTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsCreateReq nsCreateReq = new NsCreateReq(); + + @Test + public void getContext() throws Exception { + nsCreateReq.getContext(); + } + + @Test + public void setContext() throws Exception { + nsCreateReq.setContext(new CustomerModel()); + } + + @Test + public void getCsarId() throws Exception { + nsCreateReq.getCsarId(); + } + + @Test + public void setCsarId() throws Exception { + nsCreateReq.setCsarId("csarid"); + } + + @Test + public void getNsName() throws Exception { + nsCreateReq.getNsName(); + } + + @Test + public void setNsName() throws Exception { + nsCreateReq.setNsName("nsname"); + } + + @Test + public void getDescription() throws Exception { + nsCreateReq.getDescription(); + } + + @Test + public void setDescription() throws Exception { + nsCreateReq.setDescription("desc"); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java new file mode 100644 index 0000000000..330e34d0cc --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsInstantiateReqTest.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class NsInstantiateReqTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsInstantiateReq nsInstantiateReq = new NsInstantiateReq(); + + @Test + public void getNsInstanceId() throws Exception { + nsInstantiateReq.getNsInstanceId(); + } + + @Test + public void setNsInstanceId() throws Exception { + nsInstantiateReq.setNsInstanceId("test"); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java new file mode 100644 index 0000000000..e315eefbcc --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsOperationKeyTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class NsOperationKeyTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsOperationKey nsOperationKey = new NsOperationKey(); + + @Test + public void getGlobalSubscriberId() throws Exception { + nsOperationKey.getGlobalSubscriberId(); + } + + @Test + public void setGlobalSubscriberId() throws Exception { + nsOperationKey.setGlobalSubscriberId("subscriberid"); + } + + @Test + public void getServiceType() throws Exception { + nsOperationKey.getServiceType(); + } + + @Test + public void setServiceType() throws Exception { + nsOperationKey.setServiceType("servicetype"); + } + + @Test + public void getServiceId() throws Exception { + nsOperationKey.getServiceId(); + } + + @Test + public void setServiceId() throws Exception { + nsOperationKey.setServiceId("serviceid"); + } + + @Test + public void getOperationId() throws Exception { + nsOperationKey.getOperationId(); + } + + @Test + public void setOperationId() throws Exception { + nsOperationKey.setOperationId("test"); + } + + @Test + public void getNodeTemplateUUID() throws Exception { + nsOperationKey.getNodeTemplateUUID(); + } + + @Test + public void setNodeTemplateUUID() throws Exception { + nsOperationKey.setNodeTemplateUUID("nodeTemplateid"); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java new file mode 100644 index 0000000000..852bac29a1 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsParametersTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +import java.util.Collections; +import java.util.HashMap; + +public class NsParametersTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsParameters nsParameters = new NsParameters(); + + @Test + public void getLocationConstraints() throws Exception { + nsParameters.getLocationConstraints(); + } + + @Test + public void setLocationConstraints() throws Exception { + nsParameters.setLocationConstraints(Collections.emptyList()); + } + + @Test + public void getAdditionalParamForNs() throws Exception { + nsParameters.getAdditionalParamForNs(); + } + + @Test + public void setAdditionalParamForNs() throws Exception { + nsParameters.setAdditionalParamForNs(new HashMap<>()); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java new file mode 100644 index 0000000000..e99d9aef38 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/NsProgressStatusTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +import java.util.Arrays; + +public class NsProgressStatusTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + NsProgressStatus nsProgressStatus = new NsProgressStatus(); + + @Test + public void getJobId() throws Exception { + nsProgressStatus.getJobId(); + } + + @Test + public void setJobId() throws Exception { + nsProgressStatus.setJobId("jobid"); + } + + @Test + public void getResponseDescriptor() throws Exception { + nsProgressStatus.getResponseDescriptor(); + } + + @Test + public void setResponseDescriptor() throws Exception { + nsProgressStatus.setResponseDescriptor(new ResponseDescriptor()); + } + + @Test + public void getResponseHistoryList() throws Exception { + nsProgressStatus.getResponseHistoryList(); + } + + @Test + public void setResponseHistoryList() throws Exception { + nsProgressStatus.setResponseHistoryList(Arrays.asList(new ResponseDescriptor())); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java new file mode 100644 index 0000000000..a9f2f4ce3c --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/ResponseDescriptorTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class ResponseDescriptorTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + ResponseDescriptor responseDescriptor = new ResponseDescriptor(); + + @Test + public void getStatus() throws Exception { + responseDescriptor.getStatus(); + } + + @Test + public void setStatus() throws Exception { + responseDescriptor.setStatus("test"); + } + + @Test + public void getProgress() throws Exception { + responseDescriptor.getProgress(); + } + + @Test + public void setProgress() throws Exception { + responseDescriptor.setProgress("10"); + } + + @Test + public void getStatusDescription() throws Exception { + responseDescriptor.getStatusDescription(); + } + + @Test + public void setStatusDescription() throws Exception { + responseDescriptor.setStatusDescription("test"); + } + + @Test + public void getErrorCode() throws Exception { + responseDescriptor.getErrorCode(); + } + + @Test + public void setErrorCode() throws Exception { + responseDescriptor.setErrorCode(-1); + } + + @Test + public void getResponseId() throws Exception { + responseDescriptor.getResponseId(); + } + + @Test + public void setResponseId() throws Exception { + responseDescriptor.setResponseId(1); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java new file mode 100644 index 0000000000..61ddac2707 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/RestfulResponseTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +import java.util.HashMap; + +public class RestfulResponseTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + RestfulResponse restfulResponse = new RestfulResponse(); + + @Test + public void getStatus() throws Exception { + restfulResponse.getStatus(); + } + + @Test + public void setStatus() throws Exception { + restfulResponse.setStatus(1); + } + + @Test + public void getRespHeaderMap() throws Exception { + restfulResponse.getRespHeaderMap(); + } + + @Test + public void setRespHeaderMap() throws Exception { + restfulResponse.setRespHeaderMap(new HashMap<>()); + } + + @Test + public void getRespHeaderInt() throws Exception { + restfulResponse.getRespHeaderInt("1"); + } + + @Test + public void getRespHeaderLong() throws Exception { + restfulResponse.getRespHeaderLong("1"); + } + + @Test + public void getRespHeaderStr() throws Exception { + restfulResponse.getRespHeaderStr("test"); + } + + @Test + public void getResponseContent() throws Exception { + restfulResponse.getResponseContent(); + } + + @Test + public void setResponseContent() throws Exception { + restfulResponse.setResponseContent("responseString"); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java new file mode 100644 index 0000000000..e9b250717d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/model/VimLocationTest.java @@ -0,0 +1,39 @@ + +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 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.vfc.model; + +import org.junit.Test; + +public class VimLocationTest { + // TODO: following test case is done for coverage + // later it should be modified for proper test. + VimLocation vimLocation = new VimLocation(); + + @Test + public void getVimId() throws Exception { + vimLocation.getVimId(); + } + + @Test + public void setVimId() throws Exception { + vimLocation.setVimId("vimid"); + } + +} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java deleted file mode 100644 index 759ceedd0f..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.adapters.vfc; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -import org.apache.commons.io.IOUtils; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.openecomp.mso.adapters.vfc.constant.CommonConstant; -import org.openecomp.mso.adapters.vfc.constant.HttpCode; -import org.openecomp.mso.adapters.vfc.model.RestfulResponse; -import org.openecomp.mso.adapters.vfc.util.RestfulUtil; -import org.openecomp.mso.adapters.vfc.util.ValidateUtil; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.requestsdb.ResourceOperationStatus; - -import mockit.Mock; -import mockit.MockUp; - -/** - * VF-C adapter UT
- *

- *

- * - * @author - * @version ONAP Amsterdam Release 2017-08-31 - */ -public class VfcAdapterTest { - - private VfcAdapterRest vfcAdapter = new VfcAdapterRest(); - - /** - * File path - */ - private static final String FILE_PATH = "src/test/resources/json/"; - - /** - * mock get request body
- * - * @param fileName - * @return - * @since ONAP Amsterdam Release - */ - public String getRequestBody(String fileName) { - return getJsonString(fileName); - } - - /** - * Mock the request body form a file
- * - * @since ONAP Amsterdam Release - */ - private void mockRestfulUtil() { - new MockUp() { - - /** - * mock get send method
- * - * @param url - * @param methodType - * @param content - * @return - * @since ONAP Amsterdam Release - */ - @Mock - public RestfulResponse send(String url, String methodType, String content) { - if(url.equals(CommonConstant.NFVO_CREATE_URL) && methodType.equals(CommonConstant.MethodType.POST)) { - return getResponse("createNsRsp.json"); - } else if(url.contains("instantiate") && methodType.equals(CommonConstant.MethodType.POST)) { - return getResponse("instantiateNsRsp.json"); - } else if(methodType.equals(CommonConstant.MethodType.DELETE)) { - return getResponse(null); - } else if(url.contains("terminate") && methodType.equals(CommonConstant.MethodType.POST)) { - return getResponse("terminateNsRsp.json"); - } else if(url.contains("/api/nslcm/v1/jobs") && methodType.equals(CommonConstant.MethodType.GET)) { - return getResponse("queryJobRsp.json"); - } else { - return null; - } - } - }; - } - - /** - * Mock the request body form a file
- * - * @param fileName - * @since ONAP Amsterdam Release - */ - private void mockRequestDatabase() { - new MockUp() { - - /** - * mock get resource operation status
- * - * @param request - * @return - * @since ONAP Amsterdam Release - */ - @Mock - public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, - String resourceTemplateUUID) { - ResourceOperationStatus resStatus = new ResourceOperationStatus(); - resStatus.setServiceId("111"); - resStatus.setOperationId("111"); - return resStatus; - } - - /** - * Mock update Res Oper Status
- * - * @param operStatus - * @since ONAP Amsterdam Release - */ - @Mock - public void updateResOperStatus(ResourceOperationStatus operStatus) { - - } - }; - } - - /** - * Before executing UT, start mock requst database
- * - * @since ONAP Amsterdam Release - */ - @Before - public void start() { - mockRequestDatabase(); - mockRestfulUtil(); - } - - /** - * After executing UT, close session
- * - * @since ONAP Amsterdam Release - */ - @After - public void stop() { - - } - - @Test - public void createTest() { - // get request - String createReq = getRequestBody(FILE_PATH + "createNsReq.json"); - vfcAdapter.createNfvoNs(createReq); - } - - @Test - public void deleteTest() { - // get request - String req = getRequestBody(FILE_PATH + "deleteNsReq.json"); - vfcAdapter.deleteNfvoNs(req, "9b9f02c0-298b-458a-bc9c-be3692e4f354"); - } - - @Test - public void instantiateTest() { - // get request - String req = getRequestBody(FILE_PATH + "instantiateNsReq.json"); - vfcAdapter.instantiateNfvoNs(req, "9b9f02c0-298b-458a-bc9c-be3692e4f354"); - } - - @Test - public void terminateTest() { - String req = getRequestBody(FILE_PATH + "terminateNsReq.json"); - vfcAdapter.deleteNfvoNs(req, "9b9f02c0-298b-458a-bc9c-be3692e4f354"); - } - - @Test - public void queryJobTest() { - String req = getRequestBody(FILE_PATH + "queryJobReq.json"); - vfcAdapter.queryNfvoJobStatus(req, "1"); - } - - /** - * Get json string from file.
- * - * @param file the path of file - * @return json string - * @throws IOException when fail to read - * @since ONAP Amsterdam Release 2017-9-6 - */ - @SuppressWarnings("deprecation") - private String getJsonString(final String file) { - if(ValidateUtil.isStrEmpty(file)) { - return ""; - } - - String json = null; - try { - FileInputStream fileStream = new FileInputStream(new File(file)); - json = IOUtils.toString(fileStream); - } catch(Exception e) { - Assert.fail(e.getMessage()); - } - return json; - } - - /** - * get the response from file
- * - * @param fileName - * @return - * @since ONAP Amsterdam Release - */ - private RestfulResponse getResponse(String fileName) { - RestfulResponse responseSuccess = new RestfulResponse(); - responseSuccess.setStatus(HttpCode.RESPOND_OK); - if(null != fileName) { - String jsonStr = getJsonString(FILE_PATH + fileName); - responseSuccess.setResponseContent(jsonStr); - } - return responseSuccess; - } -} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationExceptionTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationExceptionTest.java deleted file mode 100644 index 231e210bbe..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationExceptionTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.adapters.vfc.exceptions; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ApplicationExceptionTest { - private ApplicationException application = new ApplicationException(0,null); - - @Test - public void testApplicationException() { - application.setErrorCode(0); - application.setErrorMsg("ErrorMsg"); - assertEquals(application.getErrorCode(), 0); - assertEquals(application.getErrorMsg(), "ErrorMsg"); - } - - @Test - public void testbuildErrorResponse(){ - assert(application.buildErrorResponse()!=null); - } -} diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/CustomerModelTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/CustomerModelTest.java deleted file mode 100644 index 293c037eca..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/CustomerModelTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class CustomerModelTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - CustomerModel customerModel = new CustomerModel(); - - @Test - public void getGlobalCustomerId() throws Exception { - customerModel.getGlobalCustomerId(); - } - - @Test - public void setGlobalCustomerId() throws Exception { - customerModel.setGlobalCustomerId("test"); - } - - @Test - public void getServiceType() throws Exception { - customerModel.getServiceType(); - } - - @Test - public void setServiceType() throws Exception { - customerModel.setServiceType("service"); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/LocationConstraintTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/LocationConstraintTest.java deleted file mode 100644 index e4b275cd41..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/LocationConstraintTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class LocationConstraintTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - LocationConstraint locationConstraint = new LocationConstraint(); - - @Test - public void getVnfProfileId() throws Exception { - locationConstraint.getVnfProfileId(); - } - - @Test - public void setVnfProfileId() throws Exception { - locationConstraint.setVnfProfileId("profileID"); - } - - @Test - public void getLocationConstraints() throws Exception { - locationConstraint.getLocationConstraints(); - } - - @Test - public void setLocationConstraints() throws Exception { - locationConstraint.setLocationConstraints(new VimLocation()); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameterTest.java deleted file mode 100644 index 3e6aeded20..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameterTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class NSResourceInputParameterTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter(); - - @Test - public void getNsServiceName() throws Exception { - nsResourceInputParameter.getNsServiceName(); - } - - @Test - public void setNsServiceName() throws Exception { - nsResourceInputParameter.setNsServiceName("service"); - } - - @Test - public void getNsServiceDescription() throws Exception { - nsResourceInputParameter.getNsServiceDescription(); - } - - @Test - public void setNsServiceDescription() throws Exception { - nsResourceInputParameter.setNsServiceDescription("desc"); - } - - @Test - public void getNsParameters() throws Exception { - nsResourceInputParameter.getNsParameters(); - } - - @Test - public void setNsParameters() throws Exception { - nsResourceInputParameter.setNsParameters(new NsParameters()); - } - - @Test - public void getNsOperationKey() throws Exception { - nsResourceInputParameter.getNsOperationKey(); - } - - @Test - public void setNsOperationKey() throws Exception { - nsResourceInputParameter.setNsOperationKey(new NsOperationKey()); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsCreateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsCreateReqTest.java deleted file mode 100644 index 56a06173e0..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsCreateReqTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class NsCreateReqTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - NsCreateReq nsCreateReq = new NsCreateReq(); - - @Test - public void getContext() throws Exception { - nsCreateReq.getContext(); - } - - @Test - public void setContext() throws Exception { - nsCreateReq.setContext(new CustomerModel()); - } - - @Test - public void getCsarId() throws Exception { - nsCreateReq.getCsarId(); - } - - @Test - public void setCsarId() throws Exception { - nsCreateReq.setCsarId("csarid"); - } - - @Test - public void getNsName() throws Exception { - nsCreateReq.getNsName(); - } - - @Test - public void setNsName() throws Exception { - nsCreateReq.setNsName("nsname"); - } - - @Test - public void getDescription() throws Exception { - nsCreateReq.getDescription(); - } - - @Test - public void setDescription() throws Exception { - nsCreateReq.setDescription("desc"); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReqTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReqTest.java deleted file mode 100644 index d63748d9dd..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsInstantiateReqTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class NsInstantiateReqTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - NsInstantiateReq nsInstantiateReq = new NsInstantiateReq(); - - @Test - public void getNsInstanceId() throws Exception { - nsInstantiateReq.getNsInstanceId(); - } - - @Test - public void setNsInstanceId() throws Exception { - nsInstantiateReq.setNsInstanceId("test"); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsOperationKeyTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsOperationKeyTest.java deleted file mode 100644 index 79b5fb2b57..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsOperationKeyTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class NsOperationKeyTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - NsOperationKey nsOperationKey = new NsOperationKey(); - - @Test - public void getGlobalSubscriberId() throws Exception { - nsOperationKey.getGlobalSubscriberId(); - } - - @Test - public void setGlobalSubscriberId() throws Exception { - nsOperationKey.setGlobalSubscriberId("subscriberid"); - } - - @Test - public void getServiceType() throws Exception { - nsOperationKey.getServiceType(); - } - - @Test - public void setServiceType() throws Exception { - nsOperationKey.setServiceType("servicetype"); - } - - @Test - public void getServiceId() throws Exception { - nsOperationKey.getServiceId(); - } - - @Test - public void setServiceId() throws Exception { - nsOperationKey.setServiceId("serviceid"); - } - - @Test - public void getOperationId() throws Exception { - nsOperationKey.getOperationId(); - } - - @Test - public void setOperationId() throws Exception { - nsOperationKey.setOperationId("test"); - } - - @Test - public void getNodeTemplateUUID() throws Exception { - nsOperationKey.getNodeTemplateUUID(); - } - - @Test - public void setNodeTemplateUUID() throws Exception { - nsOperationKey.setNodeTemplateUUID("nodeTemplateid"); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsParametersTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsParametersTest.java deleted file mode 100644 index 512c061e6d..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsParametersTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -import java.util.Collections; -import java.util.HashMap; - -public class NsParametersTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - NsParameters nsParameters = new NsParameters(); - - @Test - public void getLocationConstraints() throws Exception { - nsParameters.getLocationConstraints(); - } - - @Test - public void setLocationConstraints() throws Exception { - nsParameters.setLocationConstraints(Collections.emptyList()); - } - - @Test - public void getAdditionalParamForNs() throws Exception { - nsParameters.getAdditionalParamForNs(); - } - - @Test - public void setAdditionalParamForNs() throws Exception { - nsParameters.setAdditionalParamForNs(new HashMap<>()); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatusTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatusTest.java deleted file mode 100644 index 2569631db3..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/NsProgressStatusTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -import java.util.Arrays; - -public class NsProgressStatusTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - NsProgressStatus nsProgressStatus = new NsProgressStatus(); - - @Test - public void getJobId() throws Exception { - nsProgressStatus.getJobId(); - } - - @Test - public void setJobId() throws Exception { - nsProgressStatus.setJobId("jobid"); - } - - @Test - public void getResponseDescriptor() throws Exception { - nsProgressStatus.getResponseDescriptor(); - } - - @Test - public void setResponseDescriptor() throws Exception { - nsProgressStatus.setResponseDescriptor(new ResponseDescriptor()); - } - - @Test - public void getResponseHistoryList() throws Exception { - nsProgressStatus.getResponseHistoryList(); - } - - @Test - public void setResponseHistoryList() throws Exception { - nsProgressStatus.setResponseHistoryList(Arrays.asList(new ResponseDescriptor())); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptorTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptorTest.java deleted file mode 100644 index 0bfb0df6e3..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/ResponseDescriptorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class ResponseDescriptorTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - ResponseDescriptor responseDescriptor = new ResponseDescriptor(); - - @Test - public void getStatus() throws Exception { - responseDescriptor.getStatus(); - } - - @Test - public void setStatus() throws Exception { - responseDescriptor.setStatus("test"); - } - - @Test - public void getProgress() throws Exception { - responseDescriptor.getProgress(); - } - - @Test - public void setProgress() throws Exception { - responseDescriptor.setProgress("10"); - } - - @Test - public void getStatusDescription() throws Exception { - responseDescriptor.getStatusDescription(); - } - - @Test - public void setStatusDescription() throws Exception { - responseDescriptor.setStatusDescription("test"); - } - - @Test - public void getErrorCode() throws Exception { - responseDescriptor.getErrorCode(); - } - - @Test - public void setErrorCode() throws Exception { - responseDescriptor.setErrorCode(-1); - } - - @Test - public void getResponseId() throws Exception { - responseDescriptor.getResponseId(); - } - - @Test - public void setResponseId() throws Exception { - responseDescriptor.setResponseId(1); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/RestfulResponseTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/RestfulResponseTest.java deleted file mode 100644 index 5117e73ac2..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/RestfulResponseTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -import java.util.HashMap; - -public class RestfulResponseTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - RestfulResponse restfulResponse = new RestfulResponse(); - - @Test - public void getStatus() throws Exception { - restfulResponse.getStatus(); - } - - @Test - public void setStatus() throws Exception { - restfulResponse.setStatus(1); - } - - @Test - public void getRespHeaderMap() throws Exception { - restfulResponse.getRespHeaderMap(); - } - - @Test - public void setRespHeaderMap() throws Exception { - restfulResponse.setRespHeaderMap(new HashMap<>()); - } - - @Test - public void getRespHeaderInt() throws Exception { - restfulResponse.getRespHeaderInt("1"); - } - - @Test - public void getRespHeaderLong() throws Exception { - restfulResponse.getRespHeaderLong("1"); - } - - @Test - public void getRespHeaderStr() throws Exception { - restfulResponse.getRespHeaderStr("test"); - } - - @Test - public void getResponseContent() throws Exception { - restfulResponse.getResponseContent(); - } - - @Test - public void setResponseContent() throws Exception { - restfulResponse.setResponseContent("responseString"); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/VimLocationTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/VimLocationTest.java deleted file mode 100644 index d3da7f6b3a..0000000000 --- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/model/VimLocationTest.java +++ /dev/null @@ -1,39 +0,0 @@ - -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.openecomp.mso.adapters.vfc.model; - -import org.junit.Test; - -public class VimLocationTest { - // TODO: following test case is done for coverage - // later it should be modified for proper test. - VimLocation vimLocation = new VimLocation(); - - @Test - public void getVimId() throws Exception { - vimLocation.getVimId(); - } - - @Test - public void setVimId() throws Exception { - vimLocation.setVimId("vimid"); - } - -} \ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..ab5fa612eb --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/resources/application-test.yaml @@ -0,0 +1,6 @@ +mso: + site-name: localSite + msb-ip: "127.0.0.1" + msb-port: 8080 + + diff --git a/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json b/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json index 9534e5ece5..047c81081e 100644 --- a/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json +++ b/adapters/mso-vfc-adapter/src/test/resources/json/createNsReq.json @@ -19,7 +19,7 @@ ], "additionalParamForNs":{ "externalDataNetworkName":"Flow_out_net", - "m6000_mng_ip":"181.18.20.2", + "m6000_mng_ip":"192.168.20.2", "externalCompanyFtpDataNetworkName":"Flow_out_net", "externalPluginManageNetworkName":"plugin_net_2014", "externalManageNetworkName":"mng_net_2017", diff --git a/adapters/mso-vfc-adapter/src/test/resources/json/instantiateNsReq.json b/adapters/mso-vfc-adapter/src/test/resources/json/instantiateNsReq.json index 9534e5ece5..047c81081e 100644 --- a/adapters/mso-vfc-adapter/src/test/resources/json/instantiateNsReq.json +++ b/adapters/mso-vfc-adapter/src/test/resources/json/instantiateNsReq.json @@ -19,7 +19,7 @@ ], "additionalParamForNs":{ "externalDataNetworkName":"Flow_out_net", - "m6000_mng_ip":"181.18.20.2", + "m6000_mng_ip":"192.168.20.2", "externalCompanyFtpDataNetworkName":"Flow_out_net", "externalPluginManageNetworkName":"plugin_net_2014", "externalManageNetworkName":"mng_net_2017", diff --git a/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml b/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml index 61d9c45543..c2e0098f5a 100644 --- a/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml +++ b/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml @@ -30,7 +30,10 @@ - + + + -- cgit 1.2.3-korg