summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelperTest.java117
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestHttpRest.java958
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestHttpContentExchange.java584
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulFactory.java106
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulOptions.java288
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulParametes.java229
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulResponse.java273
-rwxr-xr-xnokiav2/deployment/Dockerfile2
-rwxr-xr-xnokiav2/deployment/Dockerfile.verify20
-rw-r--r--nokiav2/deployment/pom.xml4
-rw-r--r--nokiav2/docs/development.rst2
-rw-r--r--nokiav2/docs/sampleVnfs/.gitignore2
-rw-r--r--nokiav2/docs/so.rst10
-rw-r--r--nokiav2/driver/pom.xml6
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java52
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/ISoV2LifecycleManager.java102
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java330
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoV2LifecycleManager.java421
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2HeatPackageBuilder.java216
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java35
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java5
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java174
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoV2Api.java194
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java31
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java14
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java50
-rw-r--r--nokiav2/driver/src/main/resources/self.swagger.json809
-rw-r--r--nokiav2/driver/src/main/resources/upload.html5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java3
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java44
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java559
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestCbamVnfdBuilder.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java8
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java8
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java160
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerDefinitionConsistency.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java97
-rw-r--r--nokiav2/driver/src/test/resources/application-direct.properties2
-rw-r--r--nokiav2/driver/src/test/resources/application.properties2
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.modified.vnfd.yaml39
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.original.vnfd.yaml53
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.modified.vnfd.yaml17
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.original.vnfd.yaml3
-rw-r--r--nokiav2/driverwar/pom.xml6
-rw-r--r--nokiav2/generatedapis/pom.xml26
-rw-r--r--nokiav2/generatedapis/src/main/resources/so.vnfm.json679
-rw-r--r--nokiav2/generatedapis/src/main/resources/so.vnfm.v2.json616
-rw-r--r--nokiav2/pom.xml3
-rw-r--r--zte/vmanager/docker/Dockerfile2
50 files changed, 4777 insertions, 2594 deletions
diff --git a/.gitignore b/.gitignore
index eb5a316c..627714b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
target
+.DS_store
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelperTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelperTest.java
new file mode 100644
index 00000000..9f45fa95
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/ReaderHelperTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+public class ReaderHelperTest {
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
+ */
+ @Test
+ public void testGetLine() {
+ final String message = "hello.. how are you?";
+ final Reader reader = new StringReader(message);
+ final ReaderHelper helper = new ReaderHelper(reader);
+ final String actual = helper.getLine();
+ assertEquals(message, actual);
+ }
+
+ /**
+ * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
+ */
+ @Test
+ public void testGetLineMultiLine() {
+ final String line1 = "hello.. how are you?";
+ final String line2 = "I am fine.";
+ final Reader reader = new StringReader(line1 + System.lineSeparator() + line2);
+ final ReaderHelper helper = new ReaderHelper(reader);
+ String actual = helper.getLine();
+ assertEquals(line1, actual);
+ actual = helper.getLine();
+ assertEquals(line2, actual);
+ actual = helper.getLine();
+ assertEquals(null, actual);
+ }
+
+ @Test
+ public void testGetLineNull() {
+ final ReaderHelper helper = new ReaderHelper(null);
+ final String actual = helper.getLine();
+ assertEquals(null, actual);
+
+ }
+
+}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestHttpRest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestHttpRest.java
new file mode 100644
index 00000000..76025f3a
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestHttpRest.java
@@ -0,0 +1,958 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.HttpExchange;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.integration.junit4.JMockit;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+@RunWith(JMockit.class)
+public class TestHttpRest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testInitHttpRest() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+ new MockUp<HttpClient>() {
+
+ @Mock
+ public void doStart() {
+ }
+ };
+ final HttpRest httpRest = new HttpRest();
+ httpRest.initHttpRest(options);
+ final Field httpClient = HttpBaseRest.class.getDeclaredField("client");
+ httpClient.setAccessible(true);
+ Assert.assertNotNull(httpClient.get(httpRest));
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws NoSuchFieldException
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testCreateRestHttpContentExchange() throws NoSuchFieldException, Exception {
+ final HttpBaseRest httpRest = new HttpRest();
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ final RestHttpContentExchange exchange = httpRest.createRestHttpContentExchange(callback);
+ assertNotNull(exchange);
+ final Field callbackField = RestHttpContentExchange.class.getDeclaredField("callback");
+ assertNotNull(callbackField);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testGetStringRestfulParametes() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parametes = new RestfulParametes();
+ parametes.put("id", "1234");
+ parametes.put("name", "some-name");
+ parametes.put("address", null);
+ parametes.putHttpContextHeader("Content-Type", "application/json");
+ parametes.putHttpContextHeader("Accept-Encoding", "*/*");
+ final RestfulResponse response = httpRest.get("path/to/service", parametes);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testGetStringRestfulParametesRestfulOptions() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulResponse response = httpRest.get("path/to/service", new RestfulParametes(), options);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testHeadStringRestfulParametes() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parametes = new RestfulParametes();
+ parametes.put("id", "1234");
+ parametes.put("name", "some-name");
+ parametes.put("address", null);
+ parametes.putHttpContextHeader("Content-Type", "");
+ parametes.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.head("path/to/service", parametes);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testHeadStringRestfulParametesRestfulOptions() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parametes = new RestfulParametes();
+ parametes.put("id", "1234");
+ parametes.put("name", "some-name");
+ parametes.put("address", null);
+ parametes.putHttpContextHeader("Content-Type", "");
+ parametes.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.head("path/to/service", parametes, options);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @param options
+ * @return
+ * @throws ServiceException
+ * @since
+ */
+ private HttpRest getHttpRest(final RestfulOptions options) throws ServiceException {
+ final HttpRest httpRest = new HttpRest();
+ {
+ new MockUp<HttpClient>() {
+
+ @Mock
+ public void doStart() {
+ }
+
+ @Mock
+ public void send(final HttpExchange exchange) throws IOException {
+ }
+ };
+ httpRest.initHttpRest(options);
+
+ }
+ return httpRest;
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testAsyncGetStringRestfulParametesRestfulAsyncCallback() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncGet("path/to/service", new RestfulParametes(), callback);
+ httpRest.asyncGet("path/to/service", new RestfulParametes(), null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncGetStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncGet("path/to/service", new RestfulParametes(), new RestfulOptions(), callback);
+ httpRest.asyncGet("path/to/service", new RestfulParametes(), new RestfulOptions(), null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testPutStringRestfulParametes() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parametes = new RestfulParametes();
+ parametes.put("id", "1234");
+ parametes.put("name", "some-name");
+ parametes.put("address", null);
+ parametes.putHttpContextHeader("Content-Type", "");
+ parametes.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.put("path/to/service", parametes);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testPutStringRestfulParametesRestfulOptions() throws ServiceException {
+
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parametes = new RestfulParametes();
+ parametes.put("id", "1234");
+ parametes.put("name", "some-name");
+ parametes.put("address", null);
+ parametes.putHttpContextHeader("Content-Type", "");
+ parametes.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.put("path/to/service", parametes, null);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncPutStringRestfulParametesRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncPut("path/to/service", new RestfulParametes(), callback);
+ httpRest.asyncPut("path/to/service", new RestfulParametes(), null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testAsyncPutStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncPut("path/to/service", new RestfulParametes(), new RestfulOptions(), callback);
+ httpRest.asyncPut("path/to/service", new RestfulParametes(), new RestfulOptions(), null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testAsyncPostStringRestfulParametesRestfulAsyncCallback() throws Exception {
+ final RestfulOptions options = new RestfulOptions();
+ options.setRestTimeout(10);
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return 99;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_EXCEPTED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncPost("path/to/service", new RestfulParametes(), options, callback);
+ httpRest.asyncPost("path/to/service", new RestfulParametes(), options, null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncPostStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+ options.setRestTimeout(10);
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncPost("path/to/service", new RestfulParametes(), options, callback);
+ httpRest.asyncPost("path/to/service", new RestfulParametes(), options, null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testDeleteStringRestfulParametes() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+
+ final RestfulResponse response = httpRest.delete("path/to/service", null);
+ assertEquals(-1, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testDeleteStringRestfulParametesRestfulOptions() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parameters = new RestfulParametes();
+ parameters.put("id", "1234");
+ parameters.put("name", "some-name");
+ parameters.put("address", null);
+ parameters.setRawData("{ \"data\"=\"sample JSON data\"");
+ parameters.putHttpContextHeader("Content-Type", "");
+ parameters.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.delete("path/to/service", parameters, options);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncDeleteStringRestfulParametesRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+ options.setRestTimeout(10);
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncDelete("path/to/service", new RestfulParametes(), callback);
+ httpRest.asyncDelete("path/to/service", new RestfulParametes(), null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncDeleteStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+ options.setRestTimeout(10);
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncDelete("path/to/service", new RestfulParametes(), options, callback);
+ httpRest.asyncDelete("path/to/service", new RestfulParametes(), options, null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testPatchStringRestfulParametes() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parameters = new RestfulParametes();
+ parameters.put("id", "1234");
+ parameters.put("name", "some-name");
+ parameters.put("address", null);
+ parameters.setRawData("{ \"data\"=\"sample JSON data\"");
+ parameters.putHttpContextHeader("Content-Type", "");
+ parameters.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.patch("path/to/service", parameters);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testPatchStringRestfulParametesRestfulOptions() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+ final RestfulParametes parameters = new RestfulParametes();
+ parameters.put("id", "1234");
+ parameters.put("name", "some-name");
+ parameters.put("address", null);
+ parameters.setRawData("{ \"data\"=\"sample JSON data\"");
+ parameters.putHttpContextHeader("Content-Type", "");
+ parameters.putHttpContextHeader("Accept-Encoding", "");
+ final RestfulResponse response = httpRest.patch("path/to/service", parameters, options);
+ assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncPatchStringRestfulParametesRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+ options.setRestTimeout(10);
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncPatch("path/to/service", new RestfulParametes(), callback);
+ httpRest.asyncPatch("path/to/service", new RestfulParametes(), null);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws ServiceException
+ * @since
+ */
+ @Test
+ public void testAsyncPatchStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException {
+ final RestfulOptions options = new RestfulOptions();
+ options.setRestTimeout(10);
+
+ final HttpBaseRest httpRest = getHttpRest(options);
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public int waitForDone() {
+ return HttpExchange.STATUS_COMPLETED;
+ }
+
+ @Mock
+ public RestfulResponse getResponse() throws IOException {
+ final RestfulResponse response = new RestfulResponse();
+ response.setStatus(HttpExchange.STATUS_COMPLETED);
+ return response;
+ }
+
+ };
+
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+
+ }
+
+ };
+ httpRest.asyncPatch("path/to/service", new RestfulParametes(), options, callback);
+ httpRest.asyncPatch("path/to/service", new RestfulParametes(), options, null);
+ }
+
+}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestHttpContentExchange.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestHttpContentExchange.java
new file mode 100644
index 00000000..ec03ea75
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestHttpContentExchange.java
@@ -0,0 +1,584 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.eclipse.jetty.client.Address;
+import org.eclipse.jetty.client.CachedExchange;
+import org.eclipse.jetty.client.HttpDestination;
+import org.eclipse.jetty.client.HttpExchange;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpHeaders;
+import org.eclipse.jetty.io.Buffer;
+import org.eclipse.jetty.io.ByteArrayBuffer;
+import org.eclipse.jetty.util.StringUtil;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.Mocked;
+import mockit.integration.junit4.JMockit;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+@RunWith(JMockit.class)
+public class TestRestHttpContentExchange {
+
+ @Mocked
+ HttpDestination mockedDest;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ LogManager.getLogger(RestHttpContentExchange.class).setLevel(Level.ERROR);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws IOException
+ * @since
+ */
+ @Test
+ public void testOnRequestCommitted() throws IOException {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onRequestCommitted();
+
+ LogManager.getLogger(RestHttpContentExchange.class).setLevel(Level.DEBUG);
+ exchange.onRequestCommitted();
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws IOException
+ * @since
+ */
+ @Test
+ public void testOnRequestComplete() throws IOException {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onRequestComplete();
+
+ LogManager.getLogger(RestHttpContentExchange.class).setLevel(Level.DEBUG);
+ exchange.onRequestComplete();
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testOnResponseComplete() throws Exception {
+ RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onResponseComplete();
+
+ LogManager.getLogger(RestHttpContentExchange.class).setLevel(Level.DEBUG);
+ exchange.onResponseComplete();
+
+ final AtomicInteger isCallback = new AtomicInteger(0);
+ final AtomicInteger isException = new AtomicInteger(0);
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+ isCallback.set(1);
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+ isException.set(1);
+ }
+
+ };
+
+ final Field statusField = HttpExchange.class.getDeclaredField("_status");
+ statusField.setAccessible(true);
+ exchange = new RestHttpContentExchange(false, callback);
+ statusField.set(exchange, new AtomicInteger(200));
+ exchange.setAddress(new Address("localhost", 9999));
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onResponseComplete();
+ assertEquals(1, isCallback.get());
+ assertEquals(0, isException.get());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ @Ignore
+ public void testDecompressGzipToStr() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+
+ final InputStream stream = ClassLoader.getSystemResourceAsStream("sample.txt.gz");
+ final byte[] binaryData = new byte[1024];
+ stream.read(binaryData);
+ final String expected = "sample data.";
+
+ final String actual = exchange.decompressGzipToStr(binaryData);
+
+ assertEquals(actual, expected);
+
+ new MockUp<ByteArrayInputStream>() {
+
+ @Mock
+ public int read() throws Exception {
+ throw new IOException();
+ }
+
+ @Mock
+ public int read(final byte abyte0[], final int i, final int j) {
+
+ return -1;
+ }
+
+ };
+
+ thrown.expect(IOException.class);
+ exchange.decompressGzipToStr(binaryData);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ @Ignore
+ public void testDecompressGzipToStrException() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+
+ final InputStream stream = ClassLoader.getSystemResourceAsStream("sample.txt.gz");
+ final byte[] binaryData = new byte[1024];
+ stream.read(binaryData);
+ final String expected = "sample data.";
+
+ new MockUp<GZIPInputStream>() {
+
+ @Mock
+ public void close() throws IOException {
+ throw new IOException();
+ }
+
+ };
+
+ new MockUp<InputStreamReader>() {
+
+ @Mock
+ public void close() throws IOException {
+ throw new IOException();
+ }
+
+ };
+
+ new MockUp<ByteArrayInputStream>() {
+
+ @Mock
+ public void close() throws IOException {
+ throw new IOException();
+ }
+
+ };
+
+ final String actual = exchange.decompressGzipToStr(binaryData);
+ assertEquals(actual, expected);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testDecompressGzipToStrNull() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ final String expected = "";
+ final String actual = exchange.decompressGzipToStr(null);
+
+ assertEquals(actual, expected);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testOnResponseHeaderBufferBuffer() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+
+ final Buffer name = new ByteArrayBuffer("key");
+ final Buffer value = new ByteArrayBuffer("value");
+ exchange.onResponseHeader(name, value);
+
+ new MockUp<HttpHeaders>() {
+
+ @Mock
+ public int getOrdinal(final Buffer buffer) {
+ return HttpHeaders.CONTENT_ENCODING_ORDINAL;
+ }
+
+ };
+ exchange.onResponseHeader(name, value);
+
+ new MockUp<StringUtil>() {
+
+ @Mock
+ public String asciiToLowerCase(final String s) {
+ return "gzip";
+ }
+
+ };
+ exchange.onResponseHeader(name, value);
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testOnExceptionThrowable() {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onException(new Exception());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testOnExceptionThrowableWithCallback() {
+ final AtomicInteger isCallback = new AtomicInteger(0);
+ final AtomicInteger isException = new AtomicInteger(0);
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+ isCallback.set(1);
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+ isException.set(1);
+ }
+
+ };
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(true, callback);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onException(new Exception());
+ assertEquals(0, isCallback.get());
+ assertEquals(1, isException.get());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testOnConnectionFailedThrowable() {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onConnectionFailed(new Exception());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testOnConnectionFailedThrowableException() {
+ final AtomicInteger isCallback = new AtomicInteger(0);
+ final AtomicInteger isException = new AtomicInteger(0);
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+ isCallback.set(1);
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+ isException.set(1);
+ }
+
+ };
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(true, callback);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.onConnectionFailed(new Exception());
+ assertEquals(0, isCallback.get());
+ assertEquals(1, isException.get());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testExpireHttpDestination() {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(true, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.expire(mockedDest);
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testExpireHttpDestinationException() throws Exception {
+ final AtomicInteger isCallback = new AtomicInteger(0);
+ final AtomicInteger isException = new AtomicInteger(0);
+ final List<Throwable> thrSet = new ArrayList<Throwable>();
+ final RestfulAsyncCallback callback = new RestfulAsyncCallback() {
+
+ @Override
+ public void callback(final RestfulResponse response) {
+ isCallback.set(1);
+ }
+
+ @Override
+ public void handleExcepion(final Throwable e) {
+ isException.set(1);
+ thrSet.add(e);
+ }
+
+ };
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(true, callback);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ exchange.expire(mockedDest);
+ assertEquals(0, isCallback.get());
+ assertEquals(1, isException.get());
+ assertEquals(1, thrSet.size());
+ final Throwable t = thrSet.get(0);
+ assertEquals(ServiceException.class, t.getClass());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testIsGzip() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+
+ final Buffer name = new ByteArrayBuffer("key");
+ final Buffer value = new ByteArrayBuffer("value");
+
+ new MockUp<HttpHeaders>() {
+
+ @Mock
+ public int getOrdinal(final Buffer buffer) {
+ return HttpHeaders.CONTENT_ENCODING_ORDINAL;
+ }
+
+ };
+ exchange.onResponseHeader(name, value);
+ assertFalse(exchange.isGzip());
+
+ new MockUp<StringUtil>() {
+
+ @Mock
+ public String asciiToLowerCase(final String s) {
+ return "gzip";
+ }
+
+ };
+ exchange.onResponseHeader(name, value);
+ assertTrue(exchange.isGzip());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testGetResponse() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+
+ final Field statusField = HttpExchange.class.getDeclaredField("_status");
+ statusField.setAccessible(true);
+ statusField.set(exchange, new AtomicInteger(200));
+
+ RestfulResponse response = exchange.getResponse();
+ assertEquals(0, response.getStatus());
+
+ final HttpFields fields = new HttpFields();
+ final Field headerFields = CachedExchange.class.getDeclaredField("_responseFields");
+ headerFields.setAccessible(true);
+ headerFields.set(exchange, fields);
+ response = exchange.getResponse();
+ assertEquals(0, response.getStatus());
+ fields.add("Content-Type", "application/json");
+ fields.add("Content-Encode", "UTF-8");
+ response = exchange.getResponse();
+ assertEquals(0, response.getStatus());
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws Exception
+ * @since
+ */
+ @Test
+ public void testGetResponseGzip() throws Exception {
+ final RestHttpContentExchange exchange = new RestHttpContentExchange(false, null);
+ final Address address = new Address("localhost", 9999);
+ exchange.setAddress(address);
+ exchange.setRequestURI("/the/request/uri");
+ new MockUp<RestHttpContentExchange>() {
+
+ @Mock
+ public boolean isGzip() {
+ return true;
+ }
+ };
+ final Field statusField = HttpExchange.class.getDeclaredField("_status");
+ statusField.setAccessible(true);
+ statusField.set(exchange, new AtomicInteger(200));
+
+ final RestfulResponse response = exchange.getResponse();
+ assertEquals(0, response.getStatus());
+ }
+}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulFactory.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulFactory.java
new file mode 100644
index 00000000..eccbb8d7
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulFactory.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.integration.junit4.JMockit;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+@RunWith(JMockit.class)
+public class TestRestfulFactory {
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRestInstance() {
+ Restful instance = RestfulFactory.getRestInstance("https");
+
+ new MockUp<HttpRest>() {
+
+ @Mock
+ public void initHttpRest(final RestfulOptions option) throws ServiceException {
+ throw new ServiceException();
+ }
+
+ };
+ instance = RestfulFactory.getRestInstance("http");
+ assertNotNull(instance);
+
+ instance = RestfulFactory.getRestInstance("http");
+ assertNotNull(instance);
+ }
+}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulOptions.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulOptions.java
new file mode 100644
index 00000000..48665be7
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulOptions.java
@@ -0,0 +1,288 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+
+import mockit.integration.junit4.JMockit;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+@RunWith(JMockit.class)
+public class TestRestfulOptions {
+
+ @Rule
+ final public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetPort() {
+ final RestfulOptions options = new RestfulOptions();
+ final int port = 9091;
+ assertEquals(0, options.getPort());
+ options.setPort(port);
+ assertEquals(port, options.getPort());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetPort() {
+ final RestfulOptions options = new RestfulOptions();
+ final int port = 9091;
+ assertTrue(options.setPort(port));
+ assertEquals(port, options.getPort());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetHost() {
+ final RestfulOptions options = new RestfulOptions();
+ final String host = "localhost";
+ assertEquals("", options.getHost());
+ options.setHost(host);
+ assertEquals(host, options.getHost());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetHost() {
+ final RestfulOptions options = new RestfulOptions();
+ final String host = "localhost";
+ assertTrue(options.setHost(host));
+ assertEquals(host, options.getHost());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetRestTimeout() {
+ final RestfulOptions options = new RestfulOptions();
+ int timeout = 0;
+ assertFalse(options.setRestTimeout(timeout));
+ assertEquals(0, options.getRestTimeout());
+
+ timeout = 1;
+ assertTrue(options.setRestTimeout(timeout));
+ assertEquals(timeout, options.getRestTimeout());
+
+ timeout = 10;
+ assertTrue(options.setRestTimeout(timeout));
+ assertEquals(timeout, options.getRestTimeout());
+
+ timeout = RestfulOptions.REST_OPTIONS_TIMEOUT_MAXTIMEOUT - 1;
+ assertTrue(options.setRestTimeout(timeout));
+ assertEquals(timeout, options.getRestTimeout());
+
+ timeout = RestfulOptions.REST_OPTIONS_TIMEOUT_MAXTIMEOUT;
+ assertTrue(options.setRestTimeout(timeout));
+ assertEquals(timeout, options.getRestTimeout());
+
+ timeout = RestfulOptions.REST_OPTIONS_TIMEOUT_MAXTIMEOUT + 1;
+ assertFalse(options.setRestTimeout(timeout));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRestTimeout() {
+ final RestfulOptions options = new RestfulOptions();
+ int timeout = 0;
+ assertEquals(0, options.getRestTimeout());
+
+ timeout = 1;
+ assertTrue(options.setRestTimeout(timeout));
+ assertEquals(timeout, options.getRestTimeout());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetOption() {
+ final RestfulOptions options = new RestfulOptions();
+ assertNull(options.getOption("invalid"));
+
+ options.setHost("localhost");
+ Object obj = options.getOption(RestfulClientConst.HOST_KEY_NAME);
+ assertNotNull(obj);
+ assertTrue(obj instanceof String);
+ assertEquals("localhost", obj);
+
+ final List<String> list = new ArrayList<String>();
+ list.add("data");
+ options.setOption("list", list);
+ obj = options.getOption("list");
+ assertNotNull(obj);
+ assertTrue(obj instanceof List);
+ assertSame(list, obj);
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetIntOption() {
+ final RestfulOptions options = new RestfulOptions();
+
+ assertEquals(0, options.getIntOption("count"));
+
+ options.setOption("count", 1);
+ assertEquals(1, options.getIntOption("count"));
+
+ thrown.expect(RuntimeException.class);
+
+ options.setOption("string-count", "two");
+ final int value = options.getIntOption("string-count");
+ assertEquals(2, value);
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetStringOption() {
+ final RestfulOptions options = new RestfulOptions();
+
+ assertEquals("", options.getStringOption("count"));
+
+ options.setOption("string-count", "one");
+ assertEquals("one", options.getStringOption("string-count"));
+
+ thrown.expect(RuntimeException.class);
+
+ options.setOption("count", 2);
+ final String value = options.getStringOption("count");
+ assertEquals(2, value);
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetOption() {
+ final RestfulOptions options = new RestfulOptions();
+ assertNull(options.getOption("invalid"));
+
+ options.setHost("localhost");
+ Object obj = options.getOption(RestfulClientConst.HOST_KEY_NAME);
+ assertNotNull(obj);
+ assertTrue(obj instanceof String);
+ assertEquals("localhost", obj);
+
+ final List<String> list = new ArrayList<String>();
+ list.add("data");
+ options.setOption("list", list);
+ obj = options.getOption("list");
+ assertNotNull(obj);
+ assertTrue(obj instanceof List);
+ assertSame(list, obj);
+ }
+}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulParametes.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulParametes.java
new file mode 100644
index 00000000..6b07dcb3
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulParametes.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+public class TestRestfulParametes {
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGet() {
+ final RestfulParametes params = new RestfulParametes();
+ assertNull(params.get("param"));
+ final Map<String, String> paramMap = new HashMap<String, String>();
+ params.setParamMap(paramMap);
+ paramMap.put("param", "value");
+ assertEquals("value", params.get("param"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetRawData() {
+ final RestfulParametes params = new RestfulParametes();
+ final String data = "Sample data.";
+ params.setRawData(data);
+ assertEquals(data, params.getRawData());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRawData() {
+ final RestfulParametes params = new RestfulParametes();
+ assertNull(params.getRawData());
+ final String data = "Sample data.";
+ params.setRawData(data);
+ assertEquals(data, params.getRawData());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testPut() {
+ final RestfulParametes params = new RestfulParametes();
+ params.put("somekey", "somevalue");
+ params.put("otherkey", "othervalue");
+ assertEquals("somevalue", params.get("somekey"));
+ assertEquals("othervalue", params.get("otherkey"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testPutHttpContextHeaderStringString() {
+ final RestfulParametes params = new RestfulParametes();
+ params.putHttpContextHeader("Context-Encoding", "UTF-8");
+ assertEquals("UTF-8", params.getHttpContextHeader("Context-Encoding"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testPutHttpContextHeaderStringInt() {
+ final RestfulParametes params = new RestfulParametes();
+ params.putHttpContextHeader("Expire-At", 1000);
+ assertEquals("1000", params.getHttpContextHeader("Expire-At"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetHttpContextHeader() {
+ final RestfulParametes params = new RestfulParametes();
+ params.putHttpContextHeader("Expire-At", 1000);
+ params.putHttpContextHeader("Context-Encoding", "UTF-8");
+ assertEquals("1000", params.getHttpContextHeader("Expire-At"));
+ assertEquals("UTF-8", params.getHttpContextHeader("Context-Encoding"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetParamMap() {
+ final RestfulParametes params = new RestfulParametes();
+ params.put("key", "value");
+ final Map<String, String> map = params.getParamMap();
+ assertEquals("value", map.get("key"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetParamMap() {
+ final RestfulParametes params = new RestfulParametes();
+ final Map<String, String> map = new HashMap<String, String>();
+ map.put("key", "value");
+ params.setParamMap(map);
+ assertEquals("value", params.get("key"));
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetHeaderMap() {
+ final RestfulParametes params = new RestfulParametes();
+ params.putHttpContextHeader("key", "value");
+ final Map<String, String> map = params.getHeaderMap();
+ assertEquals("value", map.get("key"));
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetHeaderMap() {
+ final RestfulParametes params = new RestfulParametes();
+ final Map<String, String> map = new HashMap<String, String>();
+ map.put("key", "value");
+ params.setHeaderMap(map);
+ assertEquals("value", params.getHttpContextHeader("key"));
+ }
+}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulResponse.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulResponse.java
new file mode 100644
index 00000000..f5f798a8
--- /dev/null
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/restclient/TestRestfulResponse.java
@@ -0,0 +1,273 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version
+ */
+public class TestRestfulResponse {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @throws java.lang.Exception
+ * @since
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetStatus() {
+ final RestfulResponse response = new RestfulResponse();
+ int actual = response.getStatus();
+ int expected = -1;
+
+ assertEquals(expected, actual);
+ expected = 202;
+ response.setStatus(expected);
+ actual = response.getStatus();
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetStatus() {
+ final RestfulResponse response = new RestfulResponse();
+ final int expected = 10;
+ response.setStatus(expected);
+ final int actual = response.getStatus();
+ assertEquals(expected, actual);
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRespHeaderMap() {
+ final RestfulResponse response = new RestfulResponse();
+ Map<String, String> expected = response.getRespHeaderMap();
+ assertNull(expected);
+ expected = new HashMap<String, String>();
+ expected.put("key", "value");
+ response.setRespHeaderMap(expected);
+ final Map<String, String> actual = response.getRespHeaderMap();
+ assertNotNull(actual);
+ assertSame(actual, expected);
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetRespHeaderMap() {
+ final RestfulResponse response = new RestfulResponse();
+ response.setRespHeaderMap(null);
+ Map<String, String> expected = response.getRespHeaderMap();
+ assertNull(expected);
+ expected = new HashMap<String, String>();
+ expected.put("key", "value");
+ response.setRespHeaderMap(expected);
+ final Map<String, String> actual = response.getRespHeaderMap();
+ assertNotNull(actual);
+ assertSame(actual, expected);
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRespHeaderInt() {
+ final RestfulResponse response = new RestfulResponse();
+ response.setRespHeaderMap(null);
+ int actual = response.getRespHeaderInt("somekey");
+ assertEquals(-1, actual);
+ final Map<String, String> headers = new HashMap<String, String>();
+ headers.put("key", "value");
+ headers.put("count", "1");
+ response.setRespHeaderMap(headers);
+ actual = response.getRespHeaderInt("somekey");
+ assertEquals(-1, actual);
+
+ actual = response.getRespHeaderInt("count");
+ assertEquals(1, actual);
+
+ thrown.expect(RuntimeException.class);
+ actual = response.getRespHeaderInt("key");
+ assertEquals(1, actual);
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRespHeaderLong() {
+ final RestfulResponse response = new RestfulResponse();
+ response.setRespHeaderMap(null);
+ long actual = response.getRespHeaderLong("somekey");
+ assertEquals(-1, actual);
+ final Map<String, String> headers = new HashMap<String, String>();
+ headers.put("key", "value");
+ headers.put("count", "1");
+ headers.put("max", "" + Long.MAX_VALUE);
+ headers.put("max++", Long.MAX_VALUE + 1 + "");
+ response.setRespHeaderMap(headers);
+ actual = response.getRespHeaderLong("somekey");
+ assertEquals(-1, actual);
+
+ actual = response.getRespHeaderLong("count");
+ assertEquals(1, actual);
+
+ actual = response.getRespHeaderLong("max");
+ assertEquals(Long.MAX_VALUE, actual);
+
+ actual = response.getRespHeaderLong("max++");
+ assertTrue(actual < 0);
+
+ thrown.expect(RuntimeException.class);
+ actual = response.getRespHeaderLong("key");
+ assertEquals(1, actual);
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetRespHeaderStr() {
+ final RestfulResponse response = new RestfulResponse();
+ response.setRespHeaderMap(null);
+ String actual = response.getRespHeaderStr("somekey");
+ assertEquals(null, actual);
+ final Map<String, String> headers = new HashMap<String, String>();
+ headers.put("key", "value");
+ headers.put("count", "1");
+ headers.put("max", "" + Long.MAX_VALUE);
+ response.setRespHeaderMap(headers);
+ actual = response.getRespHeaderStr("somekey");
+ assertEquals(null, actual);
+
+ actual = response.getRespHeaderStr("key");
+ assertEquals("value", actual);
+
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testGetResponseContent() {
+ final RestfulResponse response = new RestfulResponse();
+ assertEquals(null, response.getResponseContent());
+
+ final String content = "{ \"content\" = \"The response content\" }";
+ response.setResponseJson(content);
+ assertEquals(content, response.getResponseContent());
+ }
+
+ /**
+ * <br/>
+ *
+ * @since
+ */
+ @Test
+ public void testSetResponseJson() {
+ final RestfulResponse response = new RestfulResponse();
+ assertEquals(null, response.getResponseContent());
+
+ final String content = "{ \"content\" = \"The response content\" }";
+ response.setResponseJson(content);
+ assertEquals(content, response.getResponseContent());
+ }
+}
diff --git a/nokiav2/deployment/Dockerfile b/nokiav2/deployment/Dockerfile
index 68bdb18a..107327d2 100755
--- a/nokiav2/deployment/Dockerfile
+++ b/nokiav2/deployment/Dockerfile
@@ -12,7 +12,7 @@ RUN yum -y update && \
yum -y install mc vim tcpdump net-tools nc strace telnet unzip && \
yum clean all
COPY pom.xml pom.xml
-RUN VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell pom.xml | grep content | sed 's/.*content=//'| sed 's/-SNAPSHOT//'` ; wget -q -O driver.war "https://nexus.onap.org/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2&a=driverwar&v=${VERSION}${MODE}&e=war"
+RUN VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell pom.xml | grep content | sed 's/.*content=//'| sed 's/-SNAPSHOT//'` ; echo "Version $VERSION mode=$MODE"; wget -q -O driver.war "https://nexus.onap.org/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2&a=driverwar&v=${VERSION}${MODE}&e=war"
#Can be used for local builds instead of the previous line
#COPY driver.war .
ENV JAVA_HOME /usr/lib/jvm/jre
diff --git a/nokiav2/deployment/Dockerfile.verify b/nokiav2/deployment/Dockerfile.verify
new file mode 100755
index 00000000..107327d2
--- /dev/null
+++ b/nokiav2/deployment/Dockerfile.verify
@@ -0,0 +1,20 @@
+FROM centos:7
+WORKDIR /service
+ARG REPO
+ARG MODE
+COPY src/main/resources/docker-entrypoint.sh .
+COPY src/main/resources/LICENSE ./ONAP_LICENSE
+COPY src/main/resources/application.properties .
+RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
+RUN sed -i 's|#baseurl=http://mirror.centos.org/centos|baseurl=http://mirrors.ocf.berkeley.edu/centos|' /etc/yum.repos.d/*.repo
+RUN yum -y update && \
+ yum -y install java-1.8.0-openjdk-headless wget && \
+ yum -y install mc vim tcpdump net-tools nc strace telnet unzip && \
+ yum clean all
+COPY pom.xml pom.xml
+RUN VERSION=`echo -e "setns x=http://maven.apache.org/POM/4.0.0 \n xpath /x:project/x:version/text() "| xmllint --shell pom.xml | grep content | sed 's/.*content=//'| sed 's/-SNAPSHOT//'` ; echo "Version $VERSION mode=$MODE"; wget -q -O driver.war "https://nexus.onap.org/service/local/artifact/maven/redirect?r=${REPO}&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2&a=driverwar&v=${VERSION}${MODE}&e=war"
+#Can be used for local builds instead of the previous line
+#COPY driver.war .
+ENV JAVA_HOME /usr/lib/jvm/jre
+EXPOSE 8089
+ENTRYPOINT /service/docker-entrypoint.sh
diff --git a/nokiav2/deployment/pom.xml b/nokiav2/deployment/pom.xml
index ff9bc505..94118071 100644
--- a/nokiav2/deployment/pom.xml
+++ b/nokiav2/deployment/pom.xml
@@ -17,14 +17,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>deployment</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${driver.version}</version>
<packaging>pom</packaging>
<name>vfc/nfvo/driver/vnfm/svnfm/nokiav2/deployment</name>
<description>Nokia SVNFM driver deployment files</description>
<parent>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</parent>
<build>
<plugins>
diff --git a/nokiav2/docs/development.rst b/nokiav2/docs/development.rst
index 12c0c29e..34025c68 100644
--- a/nokiav2/docs/development.rst
+++ b/nokiav2/docs/development.rst
@@ -47,3 +47,5 @@ Recently solved issues
- Solve remaining severe & moderate license issues
+
+
diff --git a/nokiav2/docs/sampleVnfs/.gitignore b/nokiav2/docs/sampleVnfs/.gitignore
new file mode 100644
index 00000000..02c5983d
--- /dev/null
+++ b/nokiav2/docs/sampleVnfs/.gitignore
@@ -0,0 +1,2 @@
+simple_k8s
+simple_vmware
diff --git a/nokiav2/docs/so.rst b/nokiav2/docs/so.rst
index 809f4d7d..bd7c521d 100644
--- a/nokiav2/docs/so.rst
+++ b/nokiav2/docs/so.rst
@@ -15,4 +15,12 @@ will be defined for each VDU
Limitations of the current release
----------------------------------
-- at least one server instance mapping for each VDU must be supplied in the VNF activation request \ No newline at end of file
+- at least one server instance mapping for each VDU must be supplied in the VNF activation request
+
+
+Open questions
+--------------
+
+- What is the vnfVersion in Mso
+- What is the requestType in vnfCreate
+- What is the meaning of the tenantCreated field in rollback \ No newline at end of file
diff --git a/nokiav2/driver/pom.xml b/nokiav2/driver/pom.xml
index 276f265f..1c436a55 100644
--- a/nokiav2/driver/pom.xml
+++ b/nokiav2/driver/pom.xml
@@ -17,14 +17,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>driver</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${driver.version}</version>
<packaging>jar</packaging>
<name>vfc/nfvo/driver/vnfm/svnfm/nokiav2/driver</name>
<description>svnfm vnfm driver</description>
<parent>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -35,7 +35,7 @@
<dependency>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2-clients</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${driver.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
index 123f263d..1319405e 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
@@ -59,6 +59,10 @@ public class SelfRegistrationManager {
private String driverVnfmExternalIp;
@Value("${server.port}")
private String driverPort;
+ @Value("${skipLcnSubscription}")
+ private boolean skipLcnSubscription;
+ @Value("${skipSelfRegistration}")
+ private boolean skipSelfRegistration;
private volatile boolean ready = false;
SelfRegistrationManager(VnfmInfoProvider vnfmInfoProvider, MsbApiProvider msbApiProvider, CbamRestApiProvider cbamRestApiProvider) {
@@ -72,11 +76,17 @@ public class SelfRegistrationManager {
*/
public void register() {
//the order is important (only publish it's existence after the subscription has been created)
- subscribeToLcns();
+ if(!skipLcnSubscription) {
+ subscribeToLcns();
+ }
try {
- registerMicroService();
+ if(!skipSelfRegistration) {
+ registerMicroService();
+ }
} catch (RuntimeException e) {
- deleteSubscriptions();
+ if(!skipLcnSubscription) {
+ deleteSubscriptions();
+ }
throw e;
}
ready = true;
@@ -86,24 +96,28 @@ public class SelfRegistrationManager {
* De-register the VNFM driver from the micro-service bus
*/
public void deRegister() {
- try {
- logger.info("Cancelling micro service registration");
- msbApiProvider.getMsbApi().deleteMicroService(SERVICE_NAME, DRIVER_VERSION, null, null).blockingFirst();
- } catch (Exception e) {
- //ONAP throws 500 internal server error, but deletes the micro service
- boolean serviceFoundAfterDelete = false;
+ if(!skipSelfRegistration) {
try {
- msbApiProvider.getMsbApi().getMicroService_0(SERVICE_NAME, DRIVER_VERSION, null, null, null, null, null);
- serviceFoundAfterDelete = true;
- } catch (Exception e1) {
- logger.info("Unable to query " + SERVICE_NAME + " from MSB (so the service was successfully deleted)", e1);
- // the micro service was deleted (even though 500 HTTP code was reported)
- }
- if (serviceFoundAfterDelete) {
- throw buildFatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e);
+ logger.info("Cancelling micro service registration");
+ msbApiProvider.getMsbApi().deleteMicroService(SERVICE_NAME, DRIVER_VERSION, null, null).blockingFirst();
+ } catch (Exception e) {
+ //ONAP throws 500 internal server error, but deletes the micro service
+ boolean serviceFoundAfterDelete = false;
+ try {
+ msbApiProvider.getMsbApi().getMicroService_0(SERVICE_NAME, DRIVER_VERSION, null, null, null, null, null);
+ serviceFoundAfterDelete = true;
+ } catch (Exception e1) {
+ logger.info("Unable to query " + SERVICE_NAME + " from MSB (so the service was successfully deleted)", e1);
+ // the micro service was deleted (even though 500 HTTP code was reported)
+ }
+ if (serviceFoundAfterDelete) {
+ throw buildFatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e);
+ }
}
}
- deleteSubscriptions();
+ if(!skipLcnSubscription) {
+ deleteSubscriptions();
+ }
}
/**
@@ -113,7 +127,7 @@ public class SelfRegistrationManager {
*/
@VisibleForTesting
public void assureSubscription(String vnfmId) {
- if (!vnfmIdToSubscriptionId.containsKey(vnfmId)) {
+ if (!vnfmIdToSubscriptionId.containsKey(vnfmId) && !skipLcnSubscription) {
subscribeToLcn(vnfmId);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/ISoV2LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/ISoV2LifecycleManager.java
new file mode 100644
index 00000000..32cc779e
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/ISoV2LifecycleManager.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so;
+
+import javax.servlet.http.HttpServletResponse;
+import org.onap.vnfmadapter.so.v2.model.*;
+
+public interface ISoV2LifecycleManager {
+
+ /**
+ * Create the VNF in VNFM
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param request the SO VNF creation request
+ * @param httpResponse the HTTP response
+ */
+ void createVnf(String vnfIdInAai, SoV2VnfCreateRequest request, HttpServletResponse httpResponse);
+
+ /**
+ * Query VNF
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param request the VF module update request
+ * @param httpResponse the HTTP response
+ * @return the VNF query
+ */
+ SoV2VnfQueryResponse queryVnf(String vnfIdInAai, SoV2VnfQueryRequest request, HttpServletResponse httpResponse);
+
+ /**
+ * Delete the VNF in VNFM
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param request the VNF deletion request
+ * @param httpServletResponse the HTTP response
+ */
+ void delete(String vnfIdInAai, SoV2VnfDeleteRequest request, HttpServletResponse httpServletResponse);
+
+ /**
+ * Update the VNF in VNFM
+ *
+ * - only the VNF modifiable attributes are updated
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param request the SO VNF update request
+ * @param httpResponse the HTTP response
+ * @return the response the HTTP response
+ */
+ SoV2VnfUpdateResponse updateVnf(String vnfIdInAai, SoV2VnfUpdateRequest request, HttpServletResponse httpResponse);
+
+
+ /**
+ * Rollback the operation on the VNFM
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param rollback the rollback parameters
+ */
+ void rollback(String vnfIdInAai, SoV2RollbackVnfUpdate rollback, HttpServletResponse httpServletResponse);
+
+ /**
+ * Create VF module in VNFM
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param vfModuleId the identifier of the VF module in A&AI
+ * @param request the creation request
+ * @param httpResponse the HTTP response
+ */
+ void createVfModule(String vnfIdInAai, String vfModuleId, SoV2VfModuleCreateRequest request, HttpServletResponse httpResponse);
+
+ /**
+ * Delete VF module in VNFM
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param vfModuleId the identifier of the VF module in A&AI
+ * @param request the deletion request
+ * @param httpResponse the HTTP response
+ */
+ void deleteVfModule(String vnfIdInAai, String vfModuleId, SoV2VnfDeleteRequest request, HttpServletResponse httpResponse);
+
+ /**
+ * Update VF module
+ *
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param vfModuleId the identifier of the VF module in A&AI
+ * @param request the VF module update request
+ * @param httpResponse the HTTP response
+ * @return the response
+ */
+ SoV2VnfUpdateResponse updateVfModule(String vnfIdInAai, String vfModuleId, SoV2VnfUpdateRequest request, HttpServletResponse httpResponse);
+
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
deleted file mode 100644
index b368fa1f..00000000
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so;
-
-
-import com.nokia.cbam.lcm.v32.model.*;
-import com.nokia.cbam.lcm.v32.model.VimInfo;
-import java.util.ArrayList;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.GenericVnfManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.*;
-import org.onap.vnfmadapter.so.model.*;
-import org.onap.vnfmdriver.model.ExtVirtualLinkInfo;
-import org.onap.vnfmdriver.model.*;
-import org.onap.vnfmdriver.model.VnfInfo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import static java.util.Optional.of;
-import static java.util.Optional.ofNullable;
-
-import static com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum.*;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.VnfcManager.buildCbamId;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getVnfdIdFromModifyableAttributes;
-import static org.onap.vnfmadapter.so.model.SoJobStatus.*;
-
-/**
- * Responsible for providing access to AAI APIs.
- * Handles authentication and mandatory parameters.
- */
-
-@Component
-public class SoLifecycleManager {
- private final LifecycleManager lifecycleManager;
- private final VimInfoProvider vimInfoProvider;
- private final CbamRestApiProvider cbamRestApiProvider;
- private final JobManager jobManager;
- private final GenericVnfManager genericVnfManager;
-
-
- @Autowired
- SoLifecycleManager(LifecycleManagerForSo lifecycleManager, AAIExternalSystemInfoProvider vimInfoProvider, CbamRestApiProviderForSo cbamRestApiProvider, JobManagerForSo jobManager, GenericVnfManager genericVnfManager) {
- this.lifecycleManager = lifecycleManager;
- this.vimInfoProvider = vimInfoProvider;
- this.cbamRestApiProvider = cbamRestApiProvider;
- this.jobManager = jobManager;
- this.genericVnfManager = genericVnfManager;
- }
-
- /**
- * Creates the VNF in SO terminology
- *
- * @param vnfmId the identifier of the VNFM
- * @param request the VNF creation request
- * @return the VNF creation response
- */
- public SoVnfCreationResponse create(String vnfmId, SoVnfCreationRequest request) {
- SoVnfCreationResponse response = new SoVnfCreationResponse();
- LifecycleManager.VnfCreationResult result = lifecycleManager.create(vnfmId, request.getCsarId(), request.getName(), request.getDescription());
- response.setVnfId(result.getVnfInfo().getId());
- genericVnfManager.createOrUpdate(response.getVnfId(), false, vnfmId, ofNullable(request.getNsId()));
- return response;
- }
-
- /**
- * Activate the VNF in SO terminology
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param soRequest the VNF activation request
- * @param httpResponse the HTTP response
- * @return the job handler of the VNF activation
- */
- public SoJobHandler activate(String vnfmId, String vnfId, SoVnfActivationRequest soRequest, HttpServletResponse httpResponse) {
- AdditionalParameters additionalParameters = new AdditionalParameters();
- additionalParameters.setAdditionalParams(buildAdditionalParameters(soRequest.getAdditionalParams()));
- String vimId = soRequest.getVimId();
- org.onap.vnfmdriver.model.VimInfo vimInfo = vimInfoProvider.getVimInfo(vimId);
- additionalParameters.setVimType(vimTypeHeuristic(vimInfo.getUrl()));
- processVdus(soRequest, additionalParameters, vimId);
- additionalParameters.setInstantiationLevel("default");
- processNetworks(soRequest, additionalParameters, vimId);
- processZones(soRequest, additionalParameters, vimId);
- com.nokia.cbam.lcm.v32.model.VnfInfo cbamVnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION).blockingFirst();
- String onapVnfdId = getVnfdIdFromModifyableAttributes(cbamVnfInfo);
- VnfInfo vnfInfo = lifecycleManager.queryVnf(vnfmId, vnfId);
- List<ExtVirtualLinkInfo> externalVirtualLinks = new ArrayList<>();
- VnfInstantiateResponse instantiate = lifecycleManager.instantiate(vnfmId, externalVirtualLinks, httpResponse, soRequest.getAdditionalParams(), additionalParameters, vnfId, onapVnfdId, vnfInfo.getVnfdId());
- return buildJobHandler(instantiate.getJobId());
- }
-
- /**
- * Scale the VNF
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param soRequest the VNF scale request
- * @param httpResponse the HTTP response
- * @return the job handler of the VNF activation
- */
- public SoJobHandler scale(String vnfmId, String vnfId, SoVnfScaleRequest soRequest, HttpServletResponse httpResponse) {
- org.onap.vnfmdriver.model.VnfScaleRequest driverRequest = new org.onap.vnfmdriver.model.VnfScaleRequest();
- driverRequest.setAdditionalParam(buildAdditionalParameters(soRequest.getAdditionalParams()));
- driverRequest.setAspectId(soRequest.getAspectId());
- driverRequest.setNumberOfSteps(soRequest.getSteps().toString());
- driverRequest.setType(soRequest.getDirection() == SoScaleDirection.IN ? org.onap.vnfmdriver.model.ScaleDirection.IN : org.onap.vnfmdriver.model.ScaleDirection.OUT);
- return buildJobHandler(lifecycleManager.scaleVnf(vnfmId, vnfId, driverRequest, httpResponse).getJobId());
- }
-
- /**
- * Heal the VNF
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param request the VNF heal request
- * @param httpResponse the HTTP response
- * @return the job handler of the VNF activation
- */
- public SoJobHandler heal(String vnfmId, String vnfId, SoVnfHealRequest request, HttpServletResponse httpResponse) {
- org.onap.vnfmdriver.model.VnfHealRequest vnfHealRequest = new org.onap.vnfmdriver.model.VnfHealRequest();
- VnfHealRequestAffectedvm affectedVm = new VnfHealRequestAffectedvm();
- affectedVm.setVimid("notUsedByDriver");
- affectedVm.setVduid("notUsedByDriver");
- affectedVm.setVmname("unknown");
- vnfHealRequest.setAffectedvm(affectedVm);
- vnfHealRequest.setAction("heal");
- return buildJobHandler(lifecycleManager.healVnf(vnfmId, vnfId, vnfHealRequest, of(buildCbamId(request.getVnfcId())), httpResponse).getJobId());
- }
-
- /**
- * Deactivate the VNF
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param soRequest the VNF deactivation request
- * @param httpResponse the HTTP response
- * @return the job handler of the VNF activation
- */
- public SoJobHandler deactivate(String vnfmId, String vnfId, SoVnfTerminationRequest soRequest, HttpServletResponse httpResponse) {
- VnfTerminateRequest driverRequest = new VnfTerminateRequest();
- if (soRequest.getMode() == SoTerminationMode.FORCEFUL) {
- driverRequest.setTerminationType(VnfTerminationType.FORCEFUL);
- } else {
- driverRequest.setTerminationType(VnfTerminationType.GRACEFUL);
- driverRequest.setGracefulTerminationTimeout(soRequest.getGracefulTerminationTimeoutInMs().toString());
-
- }
- return buildJobHandler(lifecycleManager.terminateAndDelete(vnfmId, vnfId, driverRequest, httpResponse).getJobId());
- }
-
- /**
- * Delete the VNF
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @return the job handler of the VNF activation
- */
- public void delete(String vnfmId, String vnfId) {
- lifecycleManager.deleteVnf(vnfmId, vnfId);
- }
-
- /**
- * Execute a custom operation on a VNF
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param request the VNF custom
- * @param httpResponse the HTTP response
- * @return the job handler of the VNF activation
- */
- public SoJobHandler customOperation(String vnfmId, String vnfId, SoVnfCustomOperation request, HttpServletResponse httpResponse) {
- String operationId = request.getOperationId();
- CustomOperationRequest cbamRequest = new CustomOperationRequest();
- cbamRequest.setAdditionalParams(buildAdditionalParameters(request.getAdditionalParams()));
- return buildJobHandler(lifecycleManager.customOperation(vnfmId, vnfId, operationId, request.getAdditionalParams(), httpResponse).getJobId());
- }
-
- /**
- * @param jobId the identifier of the job
- * @param vnfmId the identifier of the VNFM
- * @return the details of the job
- */
- public SoJobDetail getJobDetails(String vnfmId, String jobId) {
- SoJobDetail jobDetail = new SoJobDetail();
- jobDetail.setJobId(jobId);
- JobStatus currentStatus = jobManager.getJob(vnfmId, jobId).getResponseDescriptor().getStatus();
- if (JobStatus.STARTED.equals(currentStatus)) {
- jobDetail.setStatus(STARTED);
- } else if (JobStatus.PROCESSING.equals(currentStatus)) {
- jobDetail.setStatus(STARTED);
- } else if (JobStatus.FINISHED.equals(currentStatus)) {
- jobDetail.setStatus(FINISHED);
- } else if (JobStatus.TIMEOUT.equals(currentStatus)) {
- jobDetail.setStatus(FAILED);
- } else {//ERROR
- jobDetail.setStatus(FAILED);
- }
- return jobDetail;
- }
-
- private VimInfo.VimInfoTypeEnum vimTypeHeuristic(String url) {
- if (url.contains("/v3")) {
- return OPENSTACK_V3_INFO;
- } else if (url.contains("/v2")) {
- return OPENSTACK_V2_INFO;
- } else {
- return VMWARE_VCLOUD_INFO;
- }
- }
-
- private Object buildAdditionalParameters(Object additionalParams) {
- return additionalParams;
- }
-
- private SoJobHandler buildJobHandler(String jobId) {
- SoJobHandler jobHandler = new SoJobHandler();
- jobHandler.setJobId(jobId);
- return jobHandler;
- }
-
- private void processVdus(SoVnfActivationRequest request, AdditionalParameters additionalParameters, String vimId) {
- if (request.getVduMappings() != null) {
- for (SoVduMapping vduMapping : request.getVduMappings()) {
- VimComputeResourceFlavour flavour = new VimComputeResourceFlavour();
- flavour.setVimId(vimId);
- flavour.setVnfdVirtualComputeDescId(vduMapping.getVduId());
- flavour.setResourceId(vduMapping.getFlavourId());
- additionalParameters.getComputeResourceFlavours().add(flavour);
- VimSoftwareImage image = new VimSoftwareImage();
- image.setVimId(vimId);
- image.setResourceId(vduMapping.getImageId());
- image.setVnfdSoftwareImageId(vduMapping.getVduId() + CbamUtils.SEPARATOR + "image");
- additionalParameters.getSoftwareImages().add(image);
- }
- }
- }
-
- private void processNetworks(SoVnfActivationRequest request, AdditionalParameters additionalParameters, String vimId) {
- if (request.getNetworkMappings() != null) {
- for (SoNetworkMapping networkMapping : request.getNetworkMappings()) {
- ExtVirtualLinkData extVirtualLinkData = createExtVirtualLinkData(additionalParameters, networkMapping.getVldId());
- extVirtualLinkData.setVimId(vimId);
- extVirtualLinkData.setResourceId(networkMapping.getNetworkProviderId());
- processAssingedAddress(networkMapping, extVirtualLinkData);
- }
- }
- }
-
- private void processAssingedAddress(SoNetworkMapping networkMapping, ExtVirtualLinkData extVirtualLinkData) {
- if (networkMapping.getAssignedAddresses() != null) {
- for (SoAssignedAddresses assignedAddresses : networkMapping.getAssignedAddresses()) {
- VnfExtCpData extCpData = createExtVirtualLinkData(extVirtualLinkData.getExtCps(), assignedAddresses.getCpdId());
- addMissing(extCpData, assignedAddresses.getIpAddress());
- }
- }
- }
-
- private void processZones(SoVnfActivationRequest request, AdditionalParameters additionalParameters, String vimId) {
- if (request.getServerMappings() != null) {
- for (SoServerMapping serverMapping : request.getServerMappings()) {
- ZoneInfo zone = locateOrCreateZone(additionalParameters.getZones(), serverMapping.getVduId());
- zone.setResourceId(serverMapping.getAvailabilityZoneId());
- zone.setVimId(vimId);
- }
- }
- }
-
- private ZoneInfo locateOrCreateZone(List<ZoneInfo> zones, String vduId) {
- for (ZoneInfo zone : zones) {
- if (zone.getId().equals(vduId)) {
- return zone;
- }
- }
- ZoneInfo zoneInfo = new ZoneInfo();
- zoneInfo.setId(vduId);
- zones.add(zoneInfo);
- return zoneInfo;
- }
-
- private void addMissing(VnfExtCpData extCpData, String ipAddress) {
- if (extCpData.getAddresses() == null) {
- extCpData.setAddresses(new ArrayList<>());
- }
- for (NetworkAddress networkAddress : extCpData.getAddresses()) {
- if (ipAddress.equals(networkAddress.getIp())) {
- return;
- }
- }
- NetworkAddress address = new NetworkAddress();
- address.setIp(ipAddress);
- extCpData.getAddresses().add(address);
- }
-
- private VnfExtCpData createExtVirtualLinkData(List<VnfExtCpData> extCps, String cpdId) {
- for (VnfExtCpData extCp : extCps) {
- if (extCp.getCpdId().equals(cpdId)) {
- return extCp;
- }
- }
- VnfExtCpData extCp = new VnfExtCpData();
- extCp.setCpdId(cpdId);
- extCps.add(extCp);
- return extCp;
- }
-
- private ExtVirtualLinkData createExtVirtualLinkData(AdditionalParameters additionalParameters, String virtualLinkId) {
- ExtVirtualLinkData nonExistingVl = new ExtVirtualLinkData();
- nonExistingVl.setExtVirtualLinkId(virtualLinkId);
- additionalParameters.getExtVirtualLinks().add(nonExistingVl);
- return nonExistingVl;
- }
-} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoV2LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoV2LifecycleManager.java
new file mode 100644
index 00000000..708f9477
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoV2LifecycleManager.java
@@ -0,0 +1,421 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so;
+
+
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.nokia.cbam.lcm.v32.model.*;
+import com.nokia.cbam.lcm.v32.model.VnfInfo;
+import java.util.*;
+import java.util.stream.Collectors;
+import javax.servlet.http.HttpServletResponse;
+import org.onap.aai.model.GenericVnf;
+import org.onap.aai.model.VfModule;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IPackageProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapR2HeatPackageBuilder;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.*;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManager;
+import org.onap.vnfmadapter.so.v2.model.*;
+import org.onap.vnfmdriver.model.ExtVirtualLinkInfo;
+import org.onap.vnfmdriver.model.*;
+import org.onap.vnfmdriver.model.ScaleDirection;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.Yaml;
+
+import static java.util.Optional.empty;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
+
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapR2HeatPackageBuilder.*;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.*;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Responsible for providing access to AAI APIs.
+ * Handles authentication and mandatory parameters.
+ */
+@Component
+public class SoV2LifecycleManager implements ISoV2LifecycleManager{
+ private static Logger logger = getLogger(SoV2LifecycleManager.class);
+ private final LifecycleManager lifecycleManager;
+ private final CbamRestApiProvider cbamRestApiProvider;
+ private final JobManager jobManager;
+ private final AAIRestApiProvider aaiRestApiProvider;
+ private final AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider;
+ private final IPackageProvider packageProvider;
+
+ @Autowired
+ SoV2LifecycleManager(LifecycleManagerForSo lifecycleManager, CbamRestApiProviderForSo cbamRestApiProvider, JobManagerForSo jobManager, AAIRestApiProvider aaiRestApiProvider, AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider, SdcPackageProvider packageProvider) {
+ this.lifecycleManager = lifecycleManager;
+ this.cbamRestApiProvider = cbamRestApiProvider;
+ this.jobManager = jobManager;
+ this.aaiRestApiProvider = aaiRestApiProvider;
+ this.aaiExternalSystemInfoProvider = aaiExternalSystemInfoProvider;
+ this.packageProvider = packageProvider;
+ }
+
+ @Override
+ public void createVnf(String vnfIdInAai, SoV2VnfCreateRequest request, HttpServletResponse httpResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ Optional<com.nokia.cbam.lcm.v32.model.VnfInfo> matchingVnf = locateVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ if (request.isFailIfExists() != null && request.isFailIfExists()) {
+ if (matchingVnf.isPresent()) {
+ throw buildFatalFailure(logger, "The VNF with " + vnfIdInAai + " identifier in A&AI can not be found in the VNFM");
+ }
+ }
+ String vnfIdInVnfm = null;
+ if (!matchingVnf.isPresent()) {
+ try {
+ LifecycleManager.VnfCreationResult creationResult = lifecycleManager.create(vnfmInfo.getVnfmId(), genericVnf.getModelVersionId(), request.getName(), vnfIdInAai);
+ vnfIdInVnfm = creationResult.getVnfInfo().getId();
+ } catch (Exception e) {
+ logger.warn("Unable to create VNF with " + vnfIdInAai + " identifier in AAI", e);
+ cleanUpVnf(vnfIdInAai, vnfmInfo, request, httpResponse);
+ }
+ } else {
+ vnfIdInVnfm = matchingVnf.get().getId();
+ }
+ try {
+ com.nokia.cbam.lcm.v32.model.VnfInfo vnfAfterCreation = cbamRestApiProvider.getCbamLcmApi(vnfmInfo.getVnfmId()).vnfsVnfInstanceIdGet(vnfIdInVnfm, CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst();
+ updateModifiableAttributes(vnfmInfo.getVnfmId(), vnfAfterCreation, request.getInputs());
+ String vimId = request.getCloudOwner() + SEPARATOR + request.getRegionName();
+ List<ExtVirtualLinkInfo> externalVirtualLinks = addExtVirtualLinks(vimId, request.getInputs());
+ JsonObject operationAdditionalParameters = new JsonObject();
+ operationAdditionalParameters.addProperty("vimId", vimId);
+ AdditionalParameters additionalParameters = buildAdditionalParameters(request, genericVnf, vimId);
+ String etsiVnfdId = packageProvider.getCbamVnfdId(genericVnf.getModelVersionId());
+ if (!vnfAfterCreation.getInstantiationState().equals(InstantiationState.INSTANTIATED)) {
+ lifecycleManager.instantiate(vnfmInfo.getVnfmId(), externalVirtualLinks, httpResponse, operationAdditionalParameters, additionalParameters, vnfIdInVnfm, genericVnf.getModelVersionId(), etsiVnfdId);
+ logger.info("The VNF in VNFM with " + vnfIdInAai + " identifier in A&AI and " + vnfIdInVnfm + " identifier in VNFM has been instantiated");
+ } else {
+ logger.info("The VNF in VNFM with " + vnfIdInAai + " identifier in A&AI and " + vnfIdInVnfm + " identifier in VNFM is already instantiated");
+ }
+ } catch (Exception e) {
+ logger.warn("The VNF in VNFM with " + vnfIdInAai + " identifier in A&AI and " + vnfIdInVnfm + " identifier in VNFM can not be instantiated", e);
+ cleanUpVnf(vnfIdInAai, vnfmInfo, request, httpResponse);
+ }
+ }
+
+ @Override
+ public SoV2VnfQueryResponse queryVnf(String vnfIdInAai, SoV2VnfQueryRequest request, HttpServletResponse httpResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ Optional<com.nokia.cbam.lcm.v32.model.VnfInfo> matchingVnf = locateVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ SoV2VnfQueryResponse response = new SoV2VnfQueryResponse();
+ response.setStatus(getStatus(vnfmInfo, matchingVnf));
+ return response;
+ }
+
+ private SoVnfStatus getStatus(VnfmInfo vnfmInfo, Optional<VnfInfo> matchingVnf) {
+ if(matchingVnf.isPresent()){
+ OperationExecution lastOperation = findLastOperation(vnfmInfo.getVnfmId(), matchingVnf.get().getId());
+ if(lastOperation.getStatus().equals(OperationStatus.FINISHED)){
+ return SoVnfStatus.ACTIVE;
+ }
+ else if(lastOperation.getStatus().equals(OperationStatus.FAILED)){
+ return SoVnfStatus.FAILED;
+ }
+ else {
+ return SoVnfStatus.UNKNOWN;
+ }
+ }
+ else{
+ return SoVnfStatus.NOTFOUND;
+ }
+ }
+
+ private void cleanUpVnf(String vnfIdInAai, VnfmInfo vnfmInfo, SoV2VnfCreateRequest request, HttpServletResponse httpServletResponse) {
+ if(request.isDeleteUponFailure() != null && request.isDeleteUponFailure()) {
+ logger.info("Cleaning up the VNF in VNFM with " + vnfIdInAai + " identifier in A&AI");
+ SoV2VnfDeleteRequest deleteRequest = new SoV2VnfDeleteRequest();
+ deleteRequest.setMsoRequest(request.getMsoRequest());
+ delete(vnfIdInAai, deleteRequest, httpServletResponse);
+ }
+ }
+
+ private AdditionalParameters buildAdditionalParameters(SoV2VnfCreateRequest request, GenericVnf genericVnf, String vimId) {
+ AdditionalParameters additionalParameters = new AdditionalParameters();
+ buildZones(additionalParameters, vimId, request.getInputs());
+ JsonObject cbamVnfd = new Gson().toJsonTree(new Yaml().load(packageProvider.getCbamVnfdId(genericVnf.getModelVersionId()))).getAsJsonObject();
+ VduMappings vduMappings = getVduToVirtualComputeDescriptoId(cbamVnfd);
+ buildFlavours(vimId, additionalParameters, request.getInputs(), vduMappings.vduIdToVirtualComputeId);
+ buildExtenstions(request, additionalParameters);
+ buildImages(vimId, vduMappings, additionalParameters, request.getInputs());
+ setInstantiationLevel(cbamVnfd, additionalParameters);
+ return additionalParameters;
+ }
+
+ private List<ExtVirtualLinkInfo> addExtVirtualLinks(String vimId, SoInput inputs) {
+ List<ExtVirtualLinkInfo> externalVirtualLinks = new ArrayList<>();
+ for (Map.Entry<String, String> netInput : filterInput(inputs, ".*" + NET_ID)) {
+ ExtVirtualLinkInfo vl = new ExtVirtualLinkInfo();
+ String ecpId = netInput.getKey().replaceAll(NET_ID + "$", "");
+ vl.setVim(new ExtVirtualLinkInfoVim());
+ vl.getVim().setVimid(vimId);
+ vl.setResourceId(netInput.getValue());
+ vl.setCpdId(ecpId);
+ externalVirtualLinks.add(vl);
+ }
+ return externalVirtualLinks;
+ }
+
+ private void setInstantiationLevel(JsonObject cbamVnfd, AdditionalParameters additionalParameters) {
+ JsonObject topologyTemplate = child(cbamVnfd, "topology_template");
+ JsonObject substitutionMappings = child(topologyTemplate, "substitution_mappings");
+ JsonObject deploymentFlavor = child(child(substitutionMappings, "capabilities"), "deployment_flavour");
+ String defaultInstantiationLevel = childElement(child(deploymentFlavor, "properties"), "default_instantiation_level_id").getAsString();
+ additionalParameters.setInstantiationLevel(defaultInstantiationLevel);
+ }
+
+ private void buildImages(String vimId, VduMappings vduMappings, AdditionalParameters additionalParameters, SoInput inputs) {
+ for (Map.Entry<String, String> imageInput : filterInput(inputs, ".*" + IMAGE_NAME)) {
+ String vduName = imageInput.getKey().replace(IMAGE_NAME, "");
+ if (vduMappings.vduIdToVirtualSoftwareId.containsKey(vduName)) {
+ VimSoftwareImage image = new VimSoftwareImage();
+ image.setVimId(vimId);
+ image.setResourceId(imageInput.getKey());
+ image.setVnfdSoftwareImageId(vduMappings.vduIdToVirtualSoftwareId.get(vduName));
+ additionalParameters.getSoftwareImages().add(image);
+ }
+ }
+ }
+
+ private void buildExtenstions(SoV2VnfCreateRequest request, AdditionalParameters additionalParameters) {
+ for (Map.Entry<String, String> extenstion : filterInput(request.getInputs(), ".*" + ETSI_MODIFIABLE_ATTRIBUTES_EXTENSTION)) {
+ VnfProperty property = new VnfProperty();
+ property.setName(extenstion.getKey().replace(ETSI_MODIFIABLE_ATTRIBUTES_EXTENSTION, ""));
+ property.setValue(extenstion.getValue());
+ additionalParameters.getExtensions().add(property);
+ }
+ }
+
+ private static class VduMappings {
+ HashMap<String, String> vduIdToVirtualComputeId = new HashMap<>();
+ HashMap<String, String> vduIdToVirtualSoftwareId = new HashMap<>();
+ }
+
+ private VduMappings getVduToVirtualComputeDescriptoId(JsonObject root) {
+ VduMappings vduMappings = new VduMappings();
+ JsonObject topologyTemplate = child(root, "topology_template");
+ JsonObject nodeTemplates = child(topologyTemplate, "node_templates");
+ for (Map.Entry<String, JsonElement> vdu : OnapR2HeatPackageBuilder.filterType(nodeTemplates, "tosca.nodes.nfv.VDU")) {
+ boolean found = false;
+ for (JsonElement requirement : childElement(vdu.getValue().getAsJsonObject(), "requirements").getAsJsonArray()) {
+ if (requirement.getAsJsonObject().has("virtual_compute")) {
+ vduMappings.vduIdToVirtualComputeId.put(vdu.getKey(), requirement.getAsJsonObject().get("virtual_compute").getAsString());
+ found = true;
+ }
+ if (requirement.getAsJsonObject().has("sw_image")) {
+ vduMappings.vduIdToVirtualSoftwareId.put(vdu.getKey(), requirement.getAsJsonObject().get("sw_image").getAsString());
+ }
+ }
+ if (!found) {
+ throw buildFatalFailure(logger, "Unable to find virtualComputeDescriptor for " + vdu.getKey() + " identifier");
+ }
+ }
+ return vduMappings;
+ }
+
+ private void buildFlavours(String vimId, AdditionalParameters additionalParameters, SoInput inputs, Map<String, String> vduToVirtualComputeDescriptoId) {
+ for (Map.Entry<String, String> input : filterInput(inputs, ".*_flavor_name")) {
+ String vduName = input.getKey().replaceAll("_flavor_name$", "");
+ VimComputeResourceFlavour flavor = new VimComputeResourceFlavour();
+ flavor.setVimId(vimId);
+ flavor.setVnfdVirtualComputeDescId(vduToVirtualComputeDescriptoId.get(vduName));
+ flavor.setResourceId(input.getValue());
+ additionalParameters.getComputeResourceFlavours().add(flavor);
+ }
+ }
+
+ private Set<Map.Entry<String, String>> filterInput(SoInput input, String pattern) {
+ return input.entrySet().stream().filter(i -> i.getKey().matches(pattern)).collect(Collectors.toSet());
+ }
+
+ private void buildZones(AdditionalParameters additionalParameters, String vimId, SoInput inputs) {
+ for (Map.Entry<String, String> input : filterInput(inputs, "availability_zone_[0-9]*")) {
+ ZoneInfo zone = new ZoneInfo();
+ zone.setId(input.getKey());
+ zone.setResourceId(input.getValue());
+ zone.setVimId(vimId);
+ additionalParameters.getZones().add(zone);
+ }
+ }
+
+ private OperationExecution findLastOperation(String vnfmId, String vnfIdInVnfm) {
+ List<OperationExecution> operationExecutions = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdOperationExecutionsGet(vnfIdInVnfm, CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst();
+ return LifecycleChangeNotificationManager.NEWEST_OPERATIONS_FIRST.sortedCopy(operationExecutions).get(0);
+ }
+
+ @Override
+ public void delete(String vnfIdInAai, SoV2VnfDeleteRequest request, HttpServletResponse httpServletResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ Optional<com.nokia.cbam.lcm.v32.model.VnfInfo> matchingVnf = locateVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ if (matchingVnf.isPresent()) {
+ VnfTerminateRequest terminateRequest = new VnfTerminateRequest();
+ terminateRequest.setTerminationType(VnfTerminationType.GRACEFUL);
+ terminateRequest.setGracefulTerminationTimeout(Long.valueOf(60 * 60 * 1000L).toString());
+ jobManager.waitForJobToFinish(lifecycleManager.terminateAndDelete(vnfmInfo.getVnfmId(), matchingVnf.get().getId(), terminateRequest, httpServletResponse));
+ }
+ }
+
+ @Override
+ public void rollback(String vnfIdInAai, SoV2RollbackVnfUpdate rollback, HttpServletResponse httpServletResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ VnfInfo vnfInfo = expectVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ ModifyVnfInfoRequest request= new ModifyVnfInfoRequest();
+ request.setExtensions(buildExtension(rollback.getOriginalVnfProperties()));
+ lifecycleManager.executeModifyVnfInfo(vnfmInfo.getVnfmId(), vnfInfo.getId(), request);
+ }
+
+ @Override
+ public void createVfModule(String vnfIdInAai, String vfModuleId, SoV2VfModuleCreateRequest request, HttpServletResponse httpResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ VnfInfo vnfInfo = expectVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ healVnfIfRequired(vnfIdInAai, httpResponse, vnfmInfo, vnfInfo);
+ executeScale(request.getScalingAspectId(), httpResponse, genericVnf, vnfmInfo, vnfInfo);
+ }
+
+ @Override
+ public void deleteVfModule(String vnfIdInAai, String vfModuleId, SoV2VnfDeleteRequest request, HttpServletResponse httpResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ VnfInfo vnfInfo = expectVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ VfModule vfModule = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnfVfModulesVfModule(genericVnf.getVnfId(), vfModuleId, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ String aspectId = vfModule.getHeatStackId();
+ executeScale(aspectId, httpResponse, genericVnf, vnfmInfo, vnfInfo);
+ healVnfIfRequired(vnfIdInAai, httpResponse, vnfmInfo, vnfInfo);
+ }
+
+ @Override
+ public SoV2VnfUpdateResponse updateVfModule(String vnfIdInAai, String vfModuleId, SoV2VnfUpdateRequest request, HttpServletResponse httpResponse) {
+ return updateVnf(vnfIdInAai, request, httpResponse);
+ }
+
+ private void executeScale(String aspectId, HttpServletResponse httpResponse, GenericVnf genericVnf, VnfmInfo vnfmInfo, VnfInfo vnfInfo) {
+ ScaleInfo scaleInfo = vnfInfo.getInstantiatedVnfInfo().getScaleStatus().stream().filter(s -> s.getAspect().equals(aspectId)).findFirst().get();
+ long expectedStepCount = genericVnf.getVfModules().stream().filter(m -> m.getHeatStackId().equals(aspectId)).count();
+ if(expectedStepCount != scaleInfo.getScaleLevel().longValue()){
+ VnfScaleRequest scaleRequest = new VnfScaleRequest();
+ scaleRequest.setAspectId(aspectId);
+ scaleRequest.setType(expectedStepCount > scaleInfo.getScaleLevel().longValue() ? ScaleDirection.OUT : ScaleDirection.IN);
+ scaleRequest.setNumberOfSteps(Long.valueOf(Math.abs(expectedStepCount - scaleInfo.getScaleLevel().longValue())).toString());
+ JobInfo jobInfo = lifecycleManager.scaleVnf(vnfmInfo.getVnfmId(), vnfInfo.getId(), scaleRequest, httpResponse);
+ jobManager.waitForJobToFinish(jobInfo);
+ }
+ }
+
+ private void healVnfIfRequired(String vnfIdInAai, HttpServletResponse httpResponse, VnfmInfo vnfmInfo, VnfInfo vnfInfo) {
+ OperationExecution lastOperation = findLastOperation(vnfmInfo.getVnfmId(), vnfIdInAai);
+ if(lastOperation.getStatus().equals(OperationStatus.FAILED)){
+ VnfHealRequest healRequest = new VnfHealRequest();
+ healRequest.setAffectedvm(new VnfHealRequestAffectedvm());
+ healRequest.setAction("reboot");
+ JobInfo jobInfo = lifecycleManager.healVnf(vnfmInfo.getVnfmId(), vnfInfo.getId(), healRequest, empty(), httpResponse);
+ jobManager.waitForJobToFinish(jobInfo);
+ }
+ }
+
+ @Override
+ public SoV2VnfUpdateResponse updateVnf(String vnfIdInAai, SoV2VnfUpdateRequest request, HttpServletResponse httpResponse) {
+ GenericVnf genericVnf = aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfIdInAai, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst();
+ VnfmInfo vnfmInfo = locateVnfm(genericVnf);
+ Optional<com.nokia.cbam.lcm.v32.model.VnfInfo> matchingVnf = locateVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ Map<String, String> specifiedExtensions = collecSpecifiedExtensions(request.getInputs());
+ SoV2VnfUpdateResponse response = new SoV2VnfUpdateResponse();
+ Map<String, String> existingProperties = matchingVnf.get().getExtensions().stream().filter(p -> specifiedExtensions.containsKey(p.getName())).collect(Collectors.toMap(vnfProperty -> vnfProperty.getName(), vnfProperty -> vnfProperty.getValue().toString()));
+ response.setOriginalVnfProperties(new OriginalVnfProperties());
+ response.getOriginalVnfProperties().putAll(existingProperties);
+ if(matchingVnf.isPresent()){
+ try{
+ ModifyVnfInfoRequest modifyRequest = new ModifyVnfInfoRequest();
+ modifyRequest.setExtensions(buildExtension(specifiedExtensions));
+ lifecycleManager.executeModifyVnfInfo(vnfmInfo.getVnfmId(), matchingVnf.get().getId(), modifyRequest);
+ response.setSuccessful(true);
+ }
+ catch (Exception e){
+ response.setSuccessful(false);
+ }
+ return response;
+ }
+ else{
+ throw buildFatalFailure(logger, "No VNF with " + vnfIdInAai + " identifier in A&AI exists in the VNFM");
+ }
+ }
+
+ private List<VnfProperty> buildExtension(Map<String, String> specifiedExtensions) {
+ return specifiedExtensions.entrySet().stream().map(e -> {
+ VnfProperty p = new VnfProperty();
+ p.setName(e.getKey());
+ p.setValue(e.getValue());
+ return p;
+ }).collect(toList());
+ }
+
+ private void updateModifiableAttributes(String vnfmId, com.nokia.cbam.lcm.v32.model.VnfInfo vnfInfo, SoInput inputs) {
+ ModifyVnfInfoRequest request = new ModifyVnfInfoRequest();
+ request.setExtensions(new ArrayList<>());
+ Map<String, String> specifedExtensions = collecSpecifiedExtensions(inputs);
+ for (Map.Entry<String, String> specifiedExtension : specifedExtensions.entrySet()) {
+ Optional<VnfProperty> exactProperty = vnfInfo.getExtensions().stream().filter(p -> p.getName().equals(specifiedExtension.getKey()) && p.getValue().equals(specifiedExtension.getValue())).findFirst();
+ if (!exactProperty.isPresent()) {
+ VnfProperty onapCsarIdProperty = new VnfProperty();
+ onapCsarIdProperty.setName(specifiedExtension.getKey());
+ onapCsarIdProperty.setValue(specifiedExtension.getValue());
+ request.getExtensions().add(onapCsarIdProperty);
+ }
+ }
+ if (!request.getExtensions().isEmpty()) {
+ lifecycleManager.executeModifyVnfInfo(vnfmId, vnfInfo.getId(), request);
+ }
+ }
+
+ private Map<String, String> collecSpecifiedExtensions(SoInput inputs) {
+ return inputs.entrySet().stream().filter(i -> i.getKey().startsWith("etsi.modifiableAttribute.")).collect(toMap(i -> i.getKey().replace("etsi.modifiableAttribute.", ""), i -> i.getValue()));
+ }
+
+ private Optional<com.nokia.cbam.lcm.v32.model.VnfInfo> locateVnfBasedOnAaiVnfId(String vnfIdInAai, VnfmInfo vnfmInfo) {
+ return cbamRestApiProvider.getCbamLcmApi(vnfmInfo.getVnfmId()).vnfsGet(CbamRestApiProvider.NOKIA_LCM_API_VERSION).blockingFirst().stream().filter(vnf -> vnf.getDescription().equals(vnfIdInAai)).findFirst();
+ }
+
+ private com.nokia.cbam.lcm.v32.model.VnfInfo expectVnfBasedOnAaiVnfId(String vnfIdInAai, VnfmInfo vnfmInfo) {
+ Optional<VnfInfo> vnfInfo = locateVnfBasedOnAaiVnfId(vnfIdInAai, vnfmInfo);
+ if(!vnfInfo.isPresent()){
+ throw buildFatalFailure(logger, "Unable to locate VNF with " + vnfIdInAai + " A&AI identifier in VNFM");
+ }
+ return vnfInfo.get();
+ }
+
+ private VnfmInfo locateVnfm(GenericVnf vnf) {
+ for (String vnfmId : aaiExternalSystemInfoProvider.getVnfms()) {
+ VnfmInfo vnfmInfo = aaiExternalSystemInfoProvider.queryVnfmInfoFromSource(vnfmId);
+ if (vnfmInfo.getType().equals(vnf.getNfType())) {
+ return vnfmInfo;
+ }
+ }
+ throw buildFatalFailure(logger, "Unable to locate a VNFM for VNF with " + vnf.getVnfId() + " identifier with " + vnf.getNfType() + " type");
+ }
+} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2HeatPackageBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2HeatPackageBuilder.java
new file mode 100644
index 00000000..f437a902
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2HeatPackageBuilder.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
+
+import com.google.common.collect.Sets;
+import com.google.gson.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager;
+import org.slf4j.Logger;
+import org.yaml.snakeyaml.Yaml;
+
+import static java.util.stream.Collectors.toSet;
+
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.*;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Transforms a CBAM package into an ONAP package
+ */
+public class OnapR2HeatPackageBuilder {
+ public static final String ETSI_MODIFIABLE_ATTRIBUTES_EXTENSTION = "etsi_modifiable_attributes_extenstion_";
+ public static final String IMAGE_NAME = "_image_name";
+ public static final String FLAVOR_NAME = "_flavor_name";
+ public static final String NET_ID = "_net_id";
+ private static Logger logger = getLogger(OnapR2HeatPackageBuilder.class);
+ public static final String BASE_ENV_FILE_NAME = "base.env";
+ public static final String BASE_YAML_FILE_NAME = "base.yaml";
+
+ private Set<String> autoManagedExtensions = Sets.newHashSet(LifecycleManager.ONAP_CSAR_ID, LifecycleManager.EXTERNAL_VNFM_ID);
+
+ Map<String, String> processVnfd(String cbamVnfd) {
+ Map<String, String> files = new HashMap<>();
+ JsonObject root = new Gson().toJsonTree(new Yaml().load(cbamVnfd)).getAsJsonObject();
+ JsonObject topologyTemplate = child(root, "topology_template");
+ JsonObject substitutionMappings = child(topologyTemplate, "substitution_mappings");
+ JsonObject capabilities = child(substitutionMappings, "capabilities");
+ JsonObject deploymentFlavour = child(capabilities, "deployment_flavour");
+ JsonArray policies = childElement(topologyTemplate, "policies").getAsJsonArray();
+ JsonObject manifest = new JsonObject();
+ manifest.addProperty("name", "ONAP VNF package");
+ manifest.addProperty("description", "");
+ JsonArray data = new JsonArray();
+ manifest.add("data", data);
+ JsonObject deploymentFlavorProperties = child(deploymentFlavour, "properties");
+ if (deploymentFlavorProperties.has("scaling_aspects")) {
+ JsonObject scalingAspects = child(deploymentFlavorProperties, "scaling_aspects");
+ for (Map.Entry<String, JsonElement> scalingAspect : scalingAspects.entrySet()) {
+ processAspect(files, data, policies, scalingAspect.getKey(), childElement(scalingAspect.getValue().getAsJsonObject(), "max_scale_level").getAsLong());
+ }
+ }
+ processBaseIncrement(topologyTemplate, files, policies, data);
+ files.put("MANIFEST.json", new GsonBuilder().setPrettyPrinting().create().toJson(manifest));
+ return files;
+ }
+
+ private void processBaseIncrement(JsonObject topologyTemplate, Map<String, String> files, JsonArray policies, JsonArray data) {
+ StringBuilder envContent = prepareEvnContent();
+ StringBuilder yamlContent = prepareYamlContent();
+ if (topologyTemplate.has("node_templates")) {
+ JsonObject nodeTemplates = child(topologyTemplate, "node_templates");
+ processEcps(nodeTemplates, envContent, yamlContent);
+ for (Map.Entry<String, JsonElement> vdu : filterType(nodeTemplates, "tosca.nodes.nfv.VDU")) {
+ addImageAndFlavor(envContent, yamlContent, vdu);
+ }
+ }
+ processModifiableAttributes(topologyTemplate, envContent, yamlContent);
+ data.add(buildManifestEntry(BASE_ENV_FILE_NAME, BASE_YAML_FILE_NAME, true));
+ files.put(BASE_ENV_FILE_NAME, envContent.toString());
+ files.put(BASE_YAML_FILE_NAME, yamlContent.toString());
+ }
+
+ private void processModifiableAttributes(JsonObject topologyTemplate, StringBuilder envContent, StringBuilder yamlContent) {
+ JsonObject capabilities = child(child(topologyTemplate, "substitution_mappings"), "capabilities");
+ if (capabilities.has("vnf")) {
+ JsonObject vnf = child(capabilities, "vnf");
+ if (vnf.has("properties")) {
+ JsonObject properties = child(vnf, "properties");
+ if (properties.has("modifiable_attributes")) {
+ JsonObject modifiableAttributes = child(properties, "modifiable_attributes");
+ if (modifiableAttributes.has("extensions")) {
+ JsonObject extensions = child(modifiableAttributes, "extensions");
+ for (Map.Entry<String, JsonElement> extension : extensions.entrySet()) {
+ if (!autoManagedExtensions.contains(extension.getKey())) {
+ addParameter(yamlContent, envContent, ETSI_MODIFIABLE_ATTRIBUTES_EXTENSTION + extension.getKey(), "Modifiable attribute", "Modifiable attribute for " + extension.getKey());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static Set<Map.Entry<String, JsonElement>> filterType(JsonObject nodeTemplates, String type) {
+ return nodeTemplates.entrySet().stream().filter(e -> e.getValue().getAsJsonObject().get("type").equals(type)).collect(toSet());
+ }
+
+ private void processEcps(JsonObject nodeTemplates, StringBuilder envContent, StringBuilder yamlContent) {
+ for (Map.Entry<String, JsonElement> node : filterType(nodeTemplates, "tosca.nodes.nfv.ECP")) {
+ envContent.append(" " + node.getKey() + NET_ID + ": PUT YOUR NETWORK ID HERE\n");
+ addYamlParameter(yamlContent, node.getKey() + NET_ID, "Network id", "Network identifier for " + node.getKey() + " ECP");
+ }
+ }
+
+ private StringBuilder prepareYamlContent() {
+ StringBuilder yamlContent = new StringBuilder();
+ yamlContent.append("heat_template_version: 2013-05-23\n");
+ yamlContent.append("parameters:\n");
+ return yamlContent;
+ }
+
+ private void processAspect(Map<String, String> files, JsonArray data, JsonArray policies, String aspectName, long maxScaleLevel) {
+ JsonObject aspect = locateAspect(locateHeatPolicy(policies), aspectName);
+ StringBuilder envContent = prepareEvnContent();
+ StringBuilder yamlContent = prepareYamlContent();
+ if (aspect.has("vdus")) {
+ processMapping(aspect, envContent, yamlContent);
+ }
+ if (maxScaleLevel > 1001) {
+ throw buildFatalFailure(logger, "Refusing to create more than 1001 scaling levels");
+ }
+ envContent.append(" etsi.scalingAspectId: "+ aspectName + "\n");
+ for (int scaleIndex = 0; scaleIndex < maxScaleLevel; scaleIndex++) {
+ String envFileName = "module_" + aspectName + "_" + scaleIndex + ".env";
+ files.put(envFileName, envContent.toString());
+ String yamlFileName = "module_" + aspectName + "_" + scaleIndex + ".yaml";
+ files.put(yamlFileName, yamlContent.toString());
+ data.add(buildManifestEntry(envFileName, yamlFileName, false));
+ }
+ }
+
+ private StringBuilder prepareEvnContent() {
+ StringBuilder envContent = new StringBuilder();
+ envContent.append("parameters:\n");
+ return envContent;
+ }
+
+ private JsonObject buildManifestEntry(String envFileName, String yamlFileName, boolean base) {
+ JsonObject manifestEntry = new JsonObject();
+ manifestEntry.addProperty("file", yamlFileName);
+ manifestEntry.addProperty("type", "HEAT");
+ manifestEntry.addProperty("isBase", Boolean.toString(base));
+ JsonArray envEntries = new JsonArray();
+ manifestEntry.add("data", envEntries);
+ JsonObject envEntry = new JsonObject();
+ envEntries.add(envEntry);
+ envEntry.addProperty("file", envFileName);
+ envEntry.addProperty("type", "HEAT_ENV");
+ return manifestEntry;
+ }
+
+ private void processMapping(JsonObject mapping, StringBuilder envContent, StringBuilder yamlContent) {
+ for (Map.Entry<String, JsonElement> vdusElement : child(mapping, "vdus").entrySet()) {
+ addImageAndFlavor(envContent, yamlContent, vdusElement);
+ }
+ if (mapping.has("externalConnectionPoints")) {
+ for (Map.Entry<String, JsonElement> externalConnectionPoints : child(mapping, "externalConnectionPoints").entrySet()) {
+ addParameter(yamlContent, envContent, externalConnectionPoints.getKey() + "_net_id", "Network id", "Network to be used for " + externalConnectionPoints.getKey() + " ECP");
+ addParameter(yamlContent, envContent, externalConnectionPoints.getKey() + "_subnet_id", "Subnet id", "Subnet to be used for " + externalConnectionPoints.getKey() + " ECP");
+ }
+ }
+ }
+
+ private void addImageAndFlavor(StringBuilder envContent, StringBuilder yamlContent, Map.Entry<String, JsonElement> vdusElement) {
+ String vdu = vdusElement.getKey();
+ addParameter(yamlContent, envContent, vdu + IMAGE_NAME, "Image name or identifier", "Image to be used for " + vdu + " VDU");
+ addParameter(yamlContent, envContent, vdu + FLAVOR_NAME, "Flavor name or identifier", "Flavor to be used for " + vdu + " VDU");
+ }
+
+ private void addParameter(StringBuilder yamlContent, StringBuilder envContent, String key, String label, String description) {
+ addYamlParameter(yamlContent, key, label, description);
+ envContent.append(" " + key + ": PUT YOUR " + label.toUpperCase() + " HERE\n");
+ }
+
+ private void addYamlParameter(StringBuilder yamlContent, String key, String label, String description) {
+ yamlContent.append(" " + key + ":\n");
+ yamlContent.append(" type: string\n");
+ yamlContent.append(" label: " + label + "\n");
+ yamlContent.append(" description: " + description + "\n");
+ }
+
+ private JsonObject locateHeatPolicy(JsonArray policies) {
+ for (int index = 0; index < policies.size(); index++) {
+ JsonObject c = policies.get(index).getAsJsonObject();
+ JsonObject policy = c.getAsJsonObject().entrySet().iterator().next().getValue().getAsJsonObject();
+ if ("tosca.policies.nfv.HeatMapping".equals(childElement(policy, "type").getAsString())) {
+ return policy;
+ }
+ }
+ throw buildFatalFailure(logger, "The heat_mapping section is missing from VNFD");
+ }
+
+ private JsonObject locateAspect(JsonObject policy, String aspectName) {
+ for (Map.Entry<String, JsonElement> aspect : child(child(policy, "properties"), "aspects").entrySet()) {
+ if (aspect.getKey().equals(aspectName)) {
+ return aspect.getValue().getAsJsonObject();
+ }
+ }
+ throw buildFatalFailure(logger, "Unable to locate " + aspectName + " in heat policy");
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java
index 8de82347..70b18c55 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java
@@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -41,7 +42,7 @@ public class OnapVnfPackageBuilder {
* @param args not used (required due to signature)
*/
public static void main(String[] args) throws Exception {
- byte[] covert = new OnapVnfPackageBuilder().covert(systemFunctions().in(), SupportedOnapPackageVersions.V1);
+ byte[] covert = new OnapVnfPackageBuilder().covert(systemFunctions().in(), SupportedOnapPackageVersions.V1TOSCA);
systemFunctions().out().write(covert);
}
@@ -55,11 +56,35 @@ public class OnapVnfPackageBuilder {
String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(cbamVnfPackage));
ByteArrayOutputStream vnfdContent = getFileInZip(new ByteArrayInputStream(cbamVnfPackage), vnfdLocation);
byte[] cbamVnfdContent = vnfdContent.toByteArray();
- String onapVnfd = SupportedOnapPackageVersions.V2 == version ?
- new OnapR2VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)) :
- new OnapR1VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8));
byte[] modifiedCbamPackage = new CbamVnfPackageBuilder().toModifiedCbamVnfPackage(cbamVnfPackage, vnfdLocation, new CbamVnfdBuilder().build(new String(cbamVnfdContent)));
- return buildNewOnapPackage(modifiedCbamPackage, onapVnfd);
+ switch (version){
+ case V1TOSCA:
+ case V2TOSCA:
+ String onapVnfd = SupportedOnapPackageVersions.V2TOSCA == version ?
+ new OnapR2VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)) :
+ new OnapR1VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8));
+ return buildNewOnapPackage(modifiedCbamPackage, onapVnfd);
+ case V2HEAT:
+ default:
+ Map<String, String> files = new OnapR2HeatPackageBuilder().processVnfd(new String(cbamVnfdContent));
+ return buildHeatOnapPackage(modifiedCbamPackage, files);
+ }
+
+ }
+
+ private byte [] buildHeatOnapPackage(byte [] modifiedCbamPackage, Map<String, String> heatFiles) throws IOException {
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ ZipOutputStream out = new ZipOutputStream(result);
+ out.putNextEntry(new ZipEntry("Artifacts/Deployment/OTHER/cbam.package.zip"));
+ out.write(modifiedCbamPackage);
+ out.closeEntry();
+ for (Map.Entry<String, String> file : heatFiles.entrySet()) {
+ out.putNextEntry(new ZipEntry(file.getKey()));
+ out.write(file.getValue().getBytes());
+ out.closeEntry();
+ }
+ out.close();
+ return result.toByteArray();
}
private byte[] buildNewOnapPackage(byte[] modifiedCbamPackage, String onapVnfd) throws IOException {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java
index 545b2d9e..b5f5a06d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java
@@ -20,6 +20,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
* The supported ONAP package versions
*/
public enum SupportedOnapPackageVersions {
- V1,
- V2
+ V1TOSCA,
+ V2TOSCA,
+ V2HEAT
} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
deleted file mode 100644
index eb6c289f..00000000
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
-
-import javax.servlet.http.HttpServletResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so.SoLifecycleManager;
-import org.onap.vnfmadapter.so.model.*;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import static javax.servlet.http.HttpServletResponse.SC_CREATED;
-
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
-import static org.springframework.web.bind.annotation.RequestMethod.*;
-
-/**
- * Responsible for providing the Nokia sVNFM REST APIs
- */
-@Controller
-@RequestMapping(value = BASE_URL + "/so")
-public class SoApi {
- private static Logger logger = getLogger(SoApi.class);
-
- private final SoLifecycleManager soLifecycleManager;
-
- @Autowired
- SoApi(SoLifecycleManager lifecycleManager) {
- this.soLifecycleManager = lifecycleManager;
- }
-
- /**
- * Create the VNF
- *
- * @param request the creation request
- * @param vnfmId the identifier of the VNFM
- * @param httpResponse the HTTP response
- * @return the descriptor of the created VNF
- */
- @RequestMapping(value = "/{vnfmId}/vnfs", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoVnfCreationResponse createVnf(@RequestBody SoVnfCreationRequest request, @PathVariable("vnfmId") String vnfmId, HttpServletResponse httpResponse) {
- logger.info("REST: Create the VNF");
- SoVnfCreationResponse response = soLifecycleManager.create(vnfmId, request);
- httpResponse.setStatus(SC_CREATED);
- return response;
- }
-
- /**
- * Activate the VNF
- *
- * @param request the activation request
- * @param vnfmId the identifier of the VNFM
- * @param httpResponse the HTTP response
- * @return the descriptor of the created VNF
- */
- @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoJobHandler activateVnf(@RequestBody SoVnfActivationRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Activate the VNF");
- return soLifecycleManager.activate(vnfmId, vnfId, request, httpResponse);
- }
-
- /**
- * Execute custom operation on the VNF
- *
- * @param request the custom operation request
- * @param vnfmId the identifier of the VNFM
- * @param httpResponse the HTTP response
- * @return the descriptor of the created VNF
- */
- @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/customOperation", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoJobHandler executeCustomOperation(@RequestBody SoVnfCustomOperation request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Execute custom operation on the VNF");
- return soLifecycleManager.customOperation(vnfmId, vnfId, request, httpResponse);
- }
-
- /**
- * Terminate the VNF
- *
- * @param request the termination request
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param httpResponse the HTTP response
- * @return the job representing the VNF termination operation
- */
- @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/terminate", method = POST, produces = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoJobHandler deactivateVnf(@RequestBody SoVnfTerminationRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Deactivate the VNF");
- return soLifecycleManager.deactivate(vnfmId, vnfId, request, httpResponse);
- }
-
- /**
- * Delete the VNF
- *
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param httpResponse the HTTP response
- */
- @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}", method = DELETE)
- public void deleteVnf(@PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Delete the VNF");
- soLifecycleManager.delete(vnfmId, vnfId);
- httpResponse.setStatus(HttpServletResponse.SC_NO_CONTENT);
- }
-
- /**
- * Query the job
- *
- * @param jobId the identifier of the job
- * @param vnfmId the identifier of the VNFM
- * @param httpResponse the HTTP response
- * @return the instantiated VNF info
- */
- @RequestMapping(value = "/{vnfmId}/jobs/{jobId}", method = GET, produces = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoJobDetail getJob(@PathVariable("vnfmId") String vnfmId, @PathVariable("jobId") String jobId, HttpServletResponse httpResponse) {
- logger.trace("REST: Query the job");
- return soLifecycleManager.getJobDetails(vnfmId, jobId);
- }
-
- /**
- * Scale the VNF (defined further in the VF-C driver integration documentation)
- *
- * @param request the scaling request
- * @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
- * @param httpResponse the HTTP response
- * @return the job representing the scaling operation
- */
- @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/scale", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoJobHandler scaleVnf(@RequestBody SoVnfScaleRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Scale the VNF");
- return soLifecycleManager.scale(vnfmId, vnfId, request, httpResponse);
- }
-
- /**
- * Heal the VNF (defined further in the VF-C driver integration documentation)
- *
- * @param request the healing request
- * @param vnfmId the identifier of the VNFM
- * @param vnfInstanceId the identifier of the VNF
- * @param httpResponse the HTTP response
- * @return the job representing the healing operation
- */
- @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/heal", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
- @ResponseBody
- public SoJobHandler healVnf(@RequestBody SoVnfHealRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfInstanceId, HttpServletResponse httpResponse) {
- logger.info("REST: Heal the VNF");
- return soLifecycleManager.heal(vnfmId, vnfInstanceId, request, httpResponse);
- }
-}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoV2Api.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoV2Api.java
new file mode 100644
index 00000000..13d4ef8e
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoV2Api.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
+
+import javax.servlet.http.HttpServletResponse;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so.SoV2LifecycleManager;
+import org.onap.vnfmadapter.so.v2.model.*;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import static javax.servlet.http.HttpServletResponse.SC_CREATED;
+import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
+
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Constants.BASE_URL;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+import static org.springframework.web.bind.annotation.RequestMethod.*;
+
+/**
+ * Responsible for providing the Nokia sVNFM REST APIs
+ */
+@Controller
+@RequestMapping(value = BASE_URL + "/so/v2")
+public class SoV2Api {
+ private static Logger logger = getLogger(SoV2Api.class);
+
+ private final SoV2LifecycleManager soLifecycleManager;
+
+ @Autowired
+ SoV2Api(SoV2LifecycleManager lifecycleManager) {
+ this.soLifecycleManager = lifecycleManager;
+ }
+
+ /**
+ * Create the VNF
+ *
+ * @param request the creation request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ * @return the descriptor of the created VNF
+ */
+ @RequestMapping(value = "/vnfs/{vnfIdInAai}", method = POST, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public void createVnf(@RequestBody SoV2VnfCreateRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, HttpServletResponse httpResponse) {
+ logger.info("REST: Create the VNF");
+ soLifecycleManager.createVnf(vnfIdInAai, request, httpResponse);
+ httpResponse.setStatus(SC_NO_CONTENT);
+ }
+
+ /**
+ * Query the VNF
+ *
+ * @param request the creation request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ * @return the descriptor of the created VNF
+ */
+ @RequestMapping(value = "/vnfs/{vnfIdInAai}", method = POST, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public SoV2VnfQueryResponse queryVnf(@RequestBody SoV2VnfQueryRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, HttpServletResponse httpResponse) {
+ logger.info("REST: Create the VNF");
+ return soLifecycleManager.queryVnf(vnfIdInAai, request, httpResponse);
+ }
+
+ /**
+ * Terminate the VNF
+ *
+ * @param request the termination request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ * @return the job representing the VNF termination operation
+ */
+ @RequestMapping(value = "/vnfs/{vnfIdInAai}", method = DELETE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public void delete(@RequestBody SoV2VnfDeleteRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, HttpServletResponse httpResponse) {
+ logger.info("REST: Deactivate the VNF");
+ soLifecycleManager.delete(vnfIdInAai, request, httpResponse);
+ httpResponse.setStatus(SC_NO_CONTENT);
+ }
+
+ /**
+ * Update the VNF
+ *
+ * @param request the creation request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ * @return the descriptor of the created VNF
+ */
+ @RequestMapping(value = "/vnfs/{vnfIdInAai}", method = PUT, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public SoV2VnfUpdateResponse updateVnf(@RequestBody SoV2VnfUpdateRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, HttpServletResponse httpResponse) {
+ logger.info("REST: Update the VNF");
+ return soLifecycleManager.updateVnf(vnfIdInAai, request, httpResponse);
+ }
+
+ /**
+ * Rollback update VNF
+ *
+ * @param request the rollback request
+ * @param httpResponse the HTTP response
+ */
+ @RequestMapping(value = "/vnfs/{vnfIdInAai}/rollback", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public void rollback(@RequestBody SoV2RollbackVnfUpdate request, @PathVariable("vnfIdInAai") String vnfIdInAai, HttpServletResponse httpResponse) {
+ logger.info("REST: Create the VF");
+ soLifecycleManager.rollback(vnfIdInAai, request, httpResponse);
+ }
+
+ /**
+ * Create the VF module
+ *
+ * @param request the creation request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ */
+ @RequestMapping(value = "/vfmodule/{vnfIdInAai}/{vfModuleId}", method = POST, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public void createVfModule(@RequestBody SoV2VfModuleCreateRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, @PathVariable("vfModuleId") String vfModuleId, HttpServletResponse httpResponse) {
+ logger.info("REST: Create the VF");
+ soLifecycleManager.createVfModule(vnfIdInAai, vfModuleId, request, httpResponse);
+ httpResponse.setStatus(SC_CREATED);
+ }
+
+ /**
+ * Terminate the VF module
+ *
+ * @param request the termination request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ */
+ @RequestMapping(value = "/vfmodule/{vnfIdInAai}/{vfModuleId}", method = DELETE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public void deleteVfModule(@RequestBody SoV2VnfDeleteRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, @PathVariable("vfModuleId") String vfModuleId, HttpServletResponse httpResponse) {
+ logger.info("REST: Deactivate the VNF");
+ soLifecycleManager.deleteVfModule(vnfIdInAai, vfModuleId, request, httpResponse);
+ httpResponse.setStatus(SC_NO_CONTENT);
+ }
+
+ /**
+ * Update the VF module
+ *
+ * @param request the creation request
+ * @param vnfIdInAai the identifier of the VNF in A&AI
+ * @param httpResponse the HTTP response
+ * @return the descriptor of the created VNF
+ */
+ @RequestMapping(value = "/vfmodule/{vnfIdInAai}/{vfModuleId}", method = PUT, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public SoV2VnfUpdateResponse updateVfModule(@RequestBody SoV2VnfUpdateRequest request, @PathVariable("vnfIdInAai") String vnfIdInAai, @PathVariable("vfModuleId") String vfModuleId, HttpServletResponse httpResponse) {
+ logger.info("REST: Update the VNF");
+ return soLifecycleManager.updateVfModule(vnfIdInAai, vfModuleId, request, httpResponse);
+ }
+
+ /**
+ * Rollback update VNF
+ *
+ * @param request the rollback request
+ * @param httpResponse the HTTP response
+ */
+ @RequestMapping(value = "/vfmodule/{vnfIdInAai}/{vfModuleId}/rollback", method = PUT, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public void rollbackVfModuleUpdate(@RequestBody SoV2RollbackVnfUpdate request, @PathVariable("vnfIdInAai") String vnfIdInAai, HttpServletResponse httpResponse) {
+ logger.info("REST: Roll back VF module update");
+ soLifecycleManager.rollback(vnfIdInAai, request, httpResponse);
+ }
+
+ /**
+ * Provides a probe for SO to test health of VNFM adapter
+ *
+ * @param httpResponse the HTTP response
+ */
+ @RequestMapping(value = "/ping", method = GET)
+ public void testLcnConnectivity(HttpServletResponse httpResponse) {
+ httpResponse.setStatus(HttpServletResponse.SC_OK);
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
index 5895108f..d1ec9e0a 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
@@ -23,7 +23,6 @@ import java.util.*;
* Represents the additional parameters to be sent during instantiation from VF-C to the driver
*/
public class AdditionalParameters {
- private VimInfoTypeEnum vimType;
private String instantiationLevel;
private List<VimComputeResourceFlavour> computeResourceFlavours = new ArrayList<>();
private List<ZoneInfo> zones = new ArrayList<>();
@@ -33,7 +32,6 @@ public class AdditionalParameters {
private List<ExtVirtualLinkData> extVirtualLinks = new ArrayList<>();
private List<VnfProperty> extensions = new ArrayList<>();
private Object additionalParams;
- private String domain;
public AdditionalParameters() {
//only used through reflection (gson)
@@ -54,20 +52,6 @@ public class AdditionalParameters {
}
/**
- * @return the type of the VIM
- */
- public VimInfoTypeEnum getVimType() {
- return vimType;
- }
-
- /**
- * @param vimType the type of the VIM
- */
- public void setVimType(VimInfoTypeEnum vimType) {
- this.vimType = vimType;
- }
-
- /**
* @return the flavours to be used for the VNF
*/
public List<VimComputeResourceFlavour> getComputeResourceFlavours() {
@@ -159,14 +143,6 @@ public class AdditionalParameters {
this.extVirtualLinks = extVirtualLinks;
}
- public String getDomain() {
- return domain;
- }
-
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
/**
* @return the extensions of the VNF modifiable attributes
*/
@@ -188,8 +164,7 @@ public class AdditionalParameters {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AdditionalParameters that = (AdditionalParameters) o;
- return vimType == that.vimType &&
- Objects.equals(domain, that.domain) &&
+ return
Objects.equals(instantiationLevel, that.instantiationLevel) &&
Objects.equals(computeResourceFlavours, that.computeResourceFlavours) &&
Objects.equals(zones, that.zones) &&
@@ -203,13 +178,12 @@ public class AdditionalParameters {
@Override
public int hashCode() {
- return Objects.hash(vimType, domain, instantiationLevel, computeResourceFlavours, zones, softwareImages, extManagedVirtualLinks, externalConnectionPointAddresses, extVirtualLinks, extensions, additionalParams);
+ return Objects.hash(instantiationLevel, computeResourceFlavours, zones, softwareImages, extManagedVirtualLinks, externalConnectionPointAddresses, extVirtualLinks, extensions, additionalParams);
}
@Override
public String toString() {
return "AdditionalParameters{" +
- "vimType=" + vimType +
", instantiationLevel='" + instantiationLevel + '\'' +
", computeResourceFlavours=" + computeResourceFlavours +
", zones=" + zones +
@@ -219,7 +193,6 @@ public class AdditionalParameters {
", extVirtualLinks=" + extVirtualLinks +
", extensions=" + extensions +
", additionalParams=" + additionalParams +
- ", domain='" + domain + '\'' +
'}';
}
} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
index 34dce147..c7d19779 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManager.java
@@ -27,10 +27,7 @@ import com.nokia.cbam.lcm.v32.model.VnfInfo;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
-import org.onap.vnfmdriver.model.JobDetailInfo;
-import org.onap.vnfmdriver.model.JobDetailInfoResponseDescriptor;
-import org.onap.vnfmdriver.model.JobResponseInfo;
-import org.onap.vnfmdriver.model.JobStatus;
+import org.onap.vnfmdriver.model.*;
import org.slf4j.Logger;
import static javax.servlet.http.HttpServletResponse.SC_SERVICE_UNAVAILABLE;
@@ -183,6 +180,15 @@ public class JobManager {
}
}
+ public void waitForJobToFinish(JobInfo jobInfo) {
+ while(true){
+ if(ongoingJobs.contains(jobInfo.getJobId())){
+ return;
+ }
+ systemFunctions().sleep(500L);
+ }
+ }
+
private JobDetailInfo getJobDetailInfoForMissingVnf(String jobId) {
if (ongoingJobs.contains(jobId)) {
return reportOngoing(jobId);
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index 7c8e2318..8e72d688 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -37,6 +37,7 @@ import org.onap.vnfmdriver.model.*;
import org.onap.vnfmdriver.model.VimInfo;
import org.onap.vnfmdriver.model.VnfInfo;
import org.slf4j.Logger;
+import org.springframework.util.StringUtils;
import org.yaml.snakeyaml.Yaml;
import static java.lang.Integer.parseInt;
@@ -176,7 +177,6 @@ public class LifecycleManager {
@SuppressWarnings("squid:S00107") //wrapping them into an object makes the code less readable
public VnfInstantiateResponse instantiate(String vnfmId, List<ExtVirtualLinkInfo> externalVirtualLinks, HttpServletResponse httpResponse, Object operationAdditionalParameters, AdditionalParameters additionalParameters, String vnfId, String onapVnfdId, String vnfmVnfdId) {
logOperationInput(vnfId, "instantiation", additionalParameters);
- validateVimType(additionalParameters.getVimType());
VnfInstantiateResponse response = new VnfInstantiateResponse();
response.setVnfInstanceId(vnfId);
String vimId = getVimId(operationAdditionalParameters);
@@ -212,7 +212,6 @@ public class LifecycleManager {
*/
public VnfInstantiateResponse createAndInstantiate(String vnfmId, VnfInstantiateRequest request, HttpServletResponse httpResponse) {
AdditionalParameters additionalParameters = convertInstantiationAdditionalParams(request.getVnfPackageId(), request.getAdditionalParam());
- validateVimType(additionalParameters.getVimType());
VnfCreationResult creationResult = create(vnfmId, request.getVnfDescriptorId(), request.getVnfInstanceName(), request.getVnfInstanceDescription());
return instantiate(vnfmId, request.getExtVirtualLink(), httpResponse, request.getAdditionalParam(), additionalParameters, creationResult.vnfInfo.getId(), request.getVnfPackageId(), creationResult.vnfdId);
}
@@ -268,31 +267,18 @@ public class LifecycleManager {
}
private com.nokia.cbam.lcm.v32.model.VimInfo addVim(AdditionalParameters additionalParameters, String vimId, GrantVNFResponseVim vim, VimInfo vimInfo) {
- if (additionalParameters.getVimType() == OPENSTACK_V2_INFO) {
- return buildOpenStackV2INFO(vimId, vim, vimInfo);
-
- } else if (additionalParameters.getVimType() == OPENSTACK_V3_INFO) {
- if (isEmpty(vimInfo.getDomain())) {
- if (isEmpty(additionalParameters.getDomain())) {
- throw buildFatalFailure(logger, "The cloud did not supply the cloud domain (Amsterdam release) and was not supplied as additional data");
- } else {
- logger.warn("Setting domain from additional parameters");
- vimInfo.setDomain(additionalParameters.getDomain());
- }
+ if (vimInfo.getType().equals("openstack")) {
+ if (StringUtils.isEmpty(vimInfo.getDomain())) {
+ return buildOpenStackV2INFO(vimId, vim, vimInfo);
+ } else {
+ return buildOpenStackV3INFO(vimId, vim, vimInfo);
}
- return buildOpenStackV3INFO(vimId, vim, vimInfo);
} else {
//OTHER VIM TYPE is not possible
return buildVcloudInfo(vimId, vimInfo);
}
}
- private void validateVimType(com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum vimType) {
- if (com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO.equals(vimType)) {
- throw buildFatalFailure(logger, "Only " + OPENSTACK_V2_INFO + ", " + OPENSTACK_V3_INFO + " and " + VMWARE_VCLOUD_INFO + " is the supported VIM types");
- }
- }
-
private String getVimId(Object additionalParams) {
return childElement(new Gson().toJsonTree(additionalParams).getAsJsonObject(), "vimId").getAsString();
}
@@ -367,7 +353,7 @@ public class LifecycleManager {
executeModifyVnfInfo(vnfmId, vnfId, request);
}
- private void executeModifyVnfInfo(String vnfmId, String vnfId, ModifyVnfInfoRequest request) {
+ public void executeModifyVnfInfo(String vnfmId, String vnfId, ModifyVnfInfoRequest request) {
try {
OperationExecution operationExecution = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdPatch(vnfId, request, NOKIA_LCM_API_VERSION).blockingFirst();
waitForOperationToFinish(vnfmId, vnfId, operationExecution.getId());
@@ -459,16 +445,16 @@ public class LifecycleManager {
* </ul>
*
* @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier of the VNF
+ * @param vnfIdInVnfm the identifier of the VNF in VNFM
* @param request the termination request
* @param httpResponse the HTTP response
* @return the job for polling the progress of the termination
*/
- public JobInfo terminateAndDelete(String vnfmId, String vnfId, VnfTerminateRequest request, HttpServletResponse httpResponse) {
- logOperationInput(vnfId, "termination", request);
- return scheduleExecution(vnfId, httpResponse, "terminateVnf", jobInfo -> {
- terminateVnf(vnfmId, vnfId, request, jobInfo);
- deleteVnf(vnfmId, vnfId);
+ public JobInfo terminateAndDelete(String vnfmId, String vnfIdInVnfm, VnfTerminateRequest request, HttpServletResponse httpResponse) {
+ logOperationInput(vnfIdInVnfm, "termination", request);
+ return scheduleExecution(vnfIdInVnfm, httpResponse, "terminateVnf", jobInfo -> {
+ terminateVnf(vnfmId, vnfIdInVnfm, request, jobInfo);
+ deleteVnf(vnfmId, vnfIdInVnfm);
});
}
@@ -528,12 +514,12 @@ public class LifecycleManager {
* Delete the VNF
*
* @param vnfmId the identifier of the VNFM
- * @param vnfId the identifier fo the VNF
+ * @param vnfIdInVnfm the identifier fo the VNF
*/
- public void deleteVnf(String vnfmId, String vnfId) {
- logger.info("Deleting VNF with {} identifier", vnfId);
- cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(null);
- logger.info("The VNF with {} identifier has been deleted", vnfId);
+ public void deleteVnf(String vnfmId, String vnfIdInVnfm) {
+ logger.info("Deleting VNF with {} identifier", vnfIdInVnfm);
+ cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfIdInVnfm, NOKIA_LCM_API_VERSION).blockingFirst(null);
+ logger.info("The VNF with {} identifier has been deleted", vnfIdInVnfm);
}
private String getVimIdFromInstantiationRequest(String vnfmId, com.nokia.cbam.lcm.v32.model.VnfInfo vnf) {
diff --git a/nokiav2/driver/src/main/resources/self.swagger.json b/nokiav2/driver/src/main/resources/self.swagger.json
index 2645cd0e..680fee4f 100644
--- a/nokiav2/driver/src/main/resources/self.swagger.json
+++ b/nokiav2/driver/src/main/resources/self.swagger.json
@@ -21,290 +21,6 @@
"version": "1.1.0"
},
"definitions": {
- "SoJobHandler": {
- "type": "object",
- "properties": {
- "jobId": {
- "required": true,
- "description": "The identifier of the job",
- "type": "string"
- }
- }
- },
- "SoJobStatus": {
- "description": "The status of the job",
- "type": "string",
- "enum": [
- "started",
- "finished",
- "failed"
- ]
- },
- "SoJobDetail": {
- "allOf": [
- {
- "$ref": "#/definitions/SoJobHandler"
- },
- {
- "type": "object",
- "properties": {
- "status": {
- "required": true,
- "description": "The status of the job",
- "$ref": "#/definitions/SoJobStatus"
- },
- "description": {
- "required": true,
- "description": "The description of the current state of the job",
- "type": "string"
- }
- }
- }
- ]
- },
- "SoVnfCreationRequest": {
- "type": "object",
- "properties": {
- "name": {
- "required": true,
- "description": "The name of the VNF",
- "type": "string"
- },
- "csarId": {
- "required": true,
- "description": "The identifier of the VNF package in SDC",
- "type": "string"
- },
- "description": {
- "required": false,
- "description": "The description of the VNF",
- "type": "string"
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoVnfCreationResponse": {
- "type": "object",
- "properties": {
- "vnfId": {
- "required": true,
- "description": "The identifier of the created VNF",
- "type": "string"
- }
- }
- },
- "SoVduMapping": {
- "type": "object",
- "properties": {
- "vduId": {
- "required": true,
- "description": "The identifier of the VDU within the VNF package",
- "type": "string"
- },
- "imageId": {
- "required": true,
- "description": "The provider id of the image to be used for the VDU",
- "type": "string"
- },
- "flavourId": {
- "required": true,
- "description": "The provider id of the flavour to be used for the VDU",
- "type": "string"
- }
- }
- },
- "SoServerMapping": {
- "type": "object",
- "description": "Maps a server instance to a VDU and availability zone",
- "properties": {
- "vduId": {
- "required": true,
- "description": "The identifier of the VDU",
- "type": "string"
- },
- "availabilityZoneId": {
- "required": false,
- "description": "The provider id of the availability zone to be used for the server instance",
- "type": "string"
- }
- }
- },
- "SoAssignedAddresses": {
- "type": "object",
- "properties": {
- "cpdId": {
- "required": true,
- "description": "The identifier of the connection point descriptor",
- "type": "string"
- },
- "ipAddress": {
- "required": true,
- "description": "The IP address to be used",
- "type": "string"
- }
- }
- },
- "SoNetworkMapping": {
- "type": "object",
- "properties": {
- "vldId": {
- "required": true,
- "description": "The identifier of the network in the VNF package",
- "type": "string"
- },
- "networkProviderId": {
- "required": true,
- "description": "The provider id of the network be used for the given purpose",
- "type": "string"
- },
- "assignedAddresses": {
- "required": true,
- "description": "The assigned network addresses",
- "type": "array",
- "items": {
- "$ref": "#/definitions/SoAssignedAddresses"
- }
- }
- }
- },
- "SoVnfActivationRequest": {
- "type": "object",
- "properties": {
- "vimId": {
- "required": true,
- "type": "string",
- "description": "The identifier of the VIM on which the VNF is to be instantiated"
- },
- "serverMappings": {
- "required": true,
- "description": "The server mappings",
- "type": "array",
- "items": {
- "$ref": "#/definitions/SoServerMapping"
- }
- },
- "vduMappings": {
- "required": true,
- "description": "The VDU mappings",
- "type": "array",
- "items": {
- "$ref": "#/definitions/SoVduMapping"
- }
- },
- "networkMappings": {
- "required": true,
- "description": "The network mappings",
- "type": "array",
- "items": {
- "$ref": "#/definitions/SoNetworkMapping"
- }
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoScaleDirection": {
- "description": "The direction of the scale",
- "type": "string",
- "enum": [
- "in",
- "out"
- ]
- },
- "SoVnfScaleRequest": {
- "type": "object",
- "properties": {
- "aspectId": {
- "type": "string",
- "description": "The identifier of the scaling aspect in the VNF package"
- },
- "steps": {
- "type": "integer",
- "description": "The expected absolute scale level"
- },
- "direction": {
- "required": true,
- "description": "The direction of the scale",
- "$ref": "#/definitions/SoScaleDirection"
- },
- "serverMappings": {
- "required": true,
- "description": "The server mappings",
- "items": {
- "$ref": "#/definitions/SoServerMapping"
- }
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoVnfCustomOperation": {
- "type": "object",
- "properties": {
- "operationId": {
- "required": true,
- "type": "string",
- "description": "The identifier of the custom operation"
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoVnfHealRequest": {
- "type": "object",
- "properties": {
- "vnfcId": {
- "type": "string",
- "description": "The identifier of the VNFC to be healed"
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoTerminationMode": {
- "description": "The way in which the VNF is terminated",
- "type": "string",
- "enum": [
- "forceful",
- "graceful"
- ]
- },
- "SoVnfTerminationRequest": {
- "type": "object",
- "properties": {
- "mode": {
- "required": true,
- "description": "The VNF termination mode",
- "$ref": "#/definitions/SoTerminationMode"
- },
- "gracefulTerminationTimeoutInMs": {
- "required": false,
- "type": "integer",
- "description": "The timeout for graceful termination. After the timeout has expired forceful termination is attempted."
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
"JobDetailInfo": {
"properties": {
"jobId": {
@@ -680,6 +396,219 @@
"VnfLifecycleChangeNotification": {
"type": "object",
"description": "The lifecycle change notifications send from CBAM"
+ },
+ "SoMsoRequest": {
+ "type": "object",
+ "properties": {
+ "requestId": {
+ "required": true,
+ "description": "The identifier of the request in SO. Used to track requests.",
+ "type": "string"
+ },
+ "serviceInstanceId": {
+ "required": true,
+ "description": "The identifier of the service instance in A&AI.",
+ "type": "string"
+ }
+ }
+ },
+ "SoV2VnfQueryRequest": {
+ "type": "object",
+ "properties": {
+ "msoRequest": {
+ "required": true,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoVnfStatus": {
+ "description": "The status of the VNF",
+ "type": "string",
+ "enum": [
+ "ACTIVE",
+ "FAILED",
+ "NOTFOUND",
+ "UNKNOWN"
+ ]
+ },
+ "SoOutput": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "SoInput": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "SoV2VnfQueryResponse": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "required": true,
+ "description": "The status of the VNF",
+ "$ref": "#/definitions/SoVnfStatus"
+ }
+ }
+ },
+ "SoV2VnfCreateRequest": {
+ "type": "object",
+ "properties": {
+ "cloudOwner": {
+ "required": true,
+ "type": "string",
+ "description": "The owner of cloud in A&AI."
+ },
+ "regionName": {
+ "required": true,
+ "type": "string",
+ "description": "The regionName of cloud in A&AI."
+ },
+ "tenantId": {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the tenant."
+ },
+ "name": {
+ "required": true,
+ "type": "string",
+ "description": "The name of the VNF."
+ },
+ "inputs": {
+ "required": false,
+ "description": "The inputs of the VNF.",
+ "$ref": "#/definitions/SoInput"
+ },
+ "failIfExists": {
+ "required": false,
+ "description": "Should the VNF creation fail if the VNF already exists. (defaults to false)",
+ "type": "boolean"
+ },
+ "deleteUponFailure": {
+ "required": false,
+ "description": "Delete VNF in case of failure. (defaults to false)",
+ "type": "boolean"
+ },
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoMsoRollback": {
+ "type": "object",
+ "description": "Generic rollback parameters",
+ "properties": {
+ "deleteIfExists": {
+ "required": true,
+ "description": "Delete the VNF if exists",
+ "type": "boolean"
+ },
+ "vnfIdInAai": {
+ "required": true,
+ "description": "The identifier of the VNF in AAI",
+ "type": "string"
+ },
+ "msoRequest": {
+ "required": true,
+ "description": "The pointer to the original request that triggered the rollback",
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "OriginalVnfProperties": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "SoV2RollbackVnfUpdate": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/SoMsoRollback"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "originalVnfProperties": {
+ "required": false,
+ "description": "The original VNF properties before the operation",
+ "$ref": "#/definitions/OriginalVnfProperties"
+ }
+ }
+ }
+ ]
+ },
+ "SoV2VnfUpdateRequest": {
+ "type": "object",
+ "properties": {
+ "inputs": {
+ "required": false,
+ "description": "The inputs of the VNF.",
+ "$ref": "#/definitions/SoInput"
+ },
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoV2VnfUpdateResponse": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/SoV2RollbackVnfUpdate"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "successful": {
+ "required": true,
+ "description": "Is the update successful. The operation can be rolled back regardless of this attribute",
+ "type": "boolean"
+ }
+ }
+ }
+ ]
+ },
+ "SoV2VnfDeleteRequest": {
+ "type": "object",
+ "properties": {
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoV2VfModuleCreateRequest": {
+ "type": "object",
+ "properties": {
+ "scalingAspectId": {
+ "required": true,
+ "description": "The identifier of the scaling aspect",
+ "type": "string"
+ },
+ "inputs": {
+ "required": false,
+ "description": "The inputs of the VNF.",
+ "$ref": "#/definitions/SoInput"
+ },
+ "failIfExists": {
+ "required": false,
+ "description": "Should the VNF creation fail if the VNF already exists. (defaults to false)",
+ "type": "boolean"
+ },
+ "deleteUponFailure": {
+ "required": false,
+ "description": "Delete VF module in case of failure. (defaults to false)",
+ "type": "boolean"
+ },
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
}
},
"paths": {
@@ -1083,56 +1012,64 @@
}
}
},
- "/so/{vnfmId}/vnfs": {
+ "/so/v2/ping": {
+ "get": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "Test VNFM driver health",
+ "description": "Test VNFM driver health",
+ "responses": {
+ "204": {
+ "description": "VNFM adapter is healthy"
+ }
+ }
+ }
+ },
+ "/so/v2/vnfs/{vnfIdInAai}/rollback": {
"post": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
],
- "summary": "VNF create",
- "description": "VNF create",
- "operationId": "vnf_create",
+ "summary": "Rollback VNF update operation",
+ "description": "Rollback VNF update operation",
+ "operationId": "rollback",
"consumes": [
"application/json"
],
- "produces": [
- "application/json"
- ],
"parameters": [
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"in": "body",
"name": "body",
- "description": "VNF creation request parameter",
+ "description": "Rollback parameters",
"required": true,
"schema": {
- "$ref": "#/definitions/SoVnfCreationRequest"
+ "$ref": "#/definitions/SoV2RollbackVnfUpdate"
}
}
],
"responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoVnfCreationResponse"
- }
+ "204": {
+ "description": "Operation has been rolled back"
}
}
}
},
- "/so/{vnfmId}/vnfs/{vnfId}": {
- "post": {
+ "/so/v2/vnfs/{vnfIdInAai}": {
+ "get": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
],
- "summary": "VNF activation",
- "description": "VNF activation",
- "operationId": "vnf_activate",
+ "summary": "VNF query",
+ "description": "VNF query",
+ "operationId": "vnf_query",
"consumes": [
"application/json"
],
@@ -1143,24 +1080,17 @@
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
+ "description": "The identifier of the VNF in A&AI.",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"in": "body",
"name": "body",
- "description": "instantiate request param",
+ "description": "VNF creation query parameter",
"required": true,
"schema": {
- "$ref": "#/definitions/SoVnfActivationRequest"
+ "$ref": "#/definitions/SoV2VnfQueryRequest"
}
}
],
@@ -1168,49 +1098,58 @@
"201": {
"description": "",
"schema": {
- "$ref": "#/definitions/SoJobHandler"
+ "$ref": "#/definitions/SoV2VnfQueryResponse"
}
+ },
+ "404": {
+ "descriotion": "The VNF does not exist on the VNFM side"
}
}
},
- "delete": {
+ "post": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VNF create",
+ "description": "VNF create",
+ "operationId": "vnf_create",
+ "consumes": [
+ "application/json"
],
- "summary": "Deletes VNF",
- "description": "Deletes the VNF. If the VNF was instantiated VNF termination must be called before VNF deletion",
- "operationId": "delete_vnf",
"parameters": [
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
"in": "path"
},
{
+ "in": "body",
+ "name": "body",
+ "description": "VNF creation query parameter",
"required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfCreateRequest"
+ }
}
],
"responses": {
"204": {
- "description": "The VNF was deleted successfully"
+ "description": "The VNF was created on the VNFM side."
+ },
+ "400": {
+ "description": "The VNF could not be instantiated on the VNFM side. Failure has been treated according to deleteUponFailure parameter"
}
}
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/scale": {
- "post": {
+ },
+ "put": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
],
- "summary": "VNF scale",
- "description": "VNF scale request",
- "operationId": "vnf_scale",
+ "summary": "VNF update",
+ "description": "VNF update",
+ "operationId": "vnf_update",
"consumes": [
"application/json"
],
@@ -1221,94 +1160,113 @@
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
"in": "path"
},
{
+ "in": "body",
+ "name": "body",
+ "description": "VNF update parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfUpdateRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The VNF update has finished. Success is indicated in the success field.",
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfUpdateResponse"
+ }
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VNF delete",
+ "description": "VNF delete",
+ "operationId": "vnf_delete",
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ {
"required": true,
"type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"in": "body",
"name": "body",
- "description": "VNF scale request parameters",
+ "description": "VNF delete parameter",
"required": true,
"schema": {
- "$ref": "#/definitions/SoVnfScaleRequest"
+ "$ref": "#/definitions/SoV2VnfDeleteRequest"
}
}
],
"responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
+ "204": {
+ "description": "The VNF was successfully deleted."
}
}
}
},
- "/so/{vnfmId}/vnfs/{vnfId}/customOperation": {
+ "/so/v2/vfmodule/{vnfIdInAai}/{vfModuleId}": {
"post": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
],
- "summary": "VNF scale",
- "description": "VNF scale request",
- "operationId": "vnf_scale",
+ "summary": "VF module create",
+ "description": "VF module create",
+ "operationId": "vf_module_create",
"consumes": [
"application/json"
],
- "produces": [
- "application/json"
- ],
"parameters": [
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"required": true,
"type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
"in": "path"
},
{
"in": "body",
"name": "body",
- "description": "VNF scale request parameters",
+ "description": "VNF creation query parameter",
"required": true,
"schema": {
- "$ref": "#/definitions/SoVnfCustomOperation"
+ "$ref": "#/definitions/SoV2VfModuleCreateRequest"
}
}
],
"responses": {
"201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
+ "description": "The VF module has been created"
}
}
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/heal": {
- "post": {
+ },
+ "put": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
],
- "summary": "VNF heal",
- "description": "VNF heal",
- "operationId": "vnf_heal",
+ "summary": "VF module update",
+ "description": "VF module update",
+ "operationId": "vf_module_update",
"consumes": [
"application/json"
],
@@ -1319,123 +1277,120 @@
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"required": true,
"type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
"in": "path"
},
{
"in": "body",
"name": "body",
- "description": "VNF heal request parameters",
+ "description": "VNF creation query parameter",
"required": true,
"schema": {
- "$ref": "#/definitions/SoVnfHealRequest"
+ "$ref": "#/definitions/SoV2VnfUpdateRequest"
}
}
],
"responses": {
"201": {
- "description": "",
"schema": {
- "$ref": "#/definitions/SoJobHandler"
+ "$ref": "#/definitions/SoV2VnfUpdateResponse"
}
}
}
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/terminate": {
- "post": {
+ },
+ "delete": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
],
- "summary": "VNF terminate",
- "description": "VNF terminate",
- "operationId": "vnf_terminate",
+ "summary": "VF module delete",
+ "description": "VF module delete",
+ "operationId": "vf_module_delete",
"consumes": [
"application/json"
],
- "produces": [
- "application/json"
- ],
"parameters": [
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"required": true,
"type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
"in": "path"
},
{
"in": "body",
"name": "body",
- "description": "VNF termination request parameters",
+ "description": "VNF delete parameter",
"required": true,
"schema": {
- "$ref": "#/definitions/SoVnfTerminationRequest"
+ "$ref": "#/definitions/SoV2VnfDeleteRequest"
}
}
],
"responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
+ "204": {
+ "description": "The VNF was successfully deleted."
}
}
}
},
- "/so/{vnfmId}/jobs/{jobId}": {
- "get": {
+ "/so/v2/vfmodule/{vnfIdInAai}/{vfModuleId}/rollback": {
+ "put": {
"tags": [
- "SO VNFM Adaptor"
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VF module update rollback",
+ "description": "VF module update rollback",
+ "operationId": "vf_module_update rollback",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
],
- "summary": "Query job status",
- "description": "Query the job status",
- "operationId": "get_jobstatus",
"parameters": [
{
"required": true,
"type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
"in": "path"
},
{
"required": true,
"type": "string",
- "description": "The identifier of the job",
- "name": "jobId",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
"in": "path"
- }
- ],
- "responses": {
- "202": {
- "description": "The details of a job",
- "schema": {
- "$ref": "#/definitions/SoJobDetail"
- }
},
- "404": {
- "description": "The job is unknown to the VNFM. The VNFM does not keep finished jobs for forever.",
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF update rollback parameter",
+ "required": true,
"schema": {
- "$ref": "#/definitions/SoJobDetail"
+ "$ref": "#/definitions/SoV2RollbackVnfUpdate"
}
}
+ ],
+ "responses": {
+ "204": {
+ "description": "Operation has been rolled back"
+ }
}
}
}
diff --git a/nokiav2/driver/src/main/resources/upload.html b/nokiav2/driver/src/main/resources/upload.html
index ace9d2e4..907b566e 100644
--- a/nokiav2/driver/src/main/resources/upload.html
+++ b/nokiav2/driver/src/main/resources/upload.html
@@ -6,8 +6,9 @@
Select CBAM package to upload:
<input type="file" name="fileToUpload" id="fileToUpload"> ONAP package version:
<select name="version">
- <option value="V1">V1</option>
- <option value="V2" selected="selected">V2</option>
+ <option value="V1TOSCA">V1TOSCA</option>
+ <option value="V2TOSCA" selected="selected">V2TOSCA</option>
+ <option value="V2HEAT">V2HEAT</option>
</select>
<input type="submit" value="Upload" name="submit">
</form>
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java
index b37d95ff..61919e0d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java
@@ -26,7 +26,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestAAIRestApiProvi
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestGrantlessGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.TestSdcPackageProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.*;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so.TestSoLifecycleManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi.*;
@@ -58,8 +57,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestReportedA
TestGrantlessGrantManager.class,
TestSdcPackageProvider.class,
- TestSoLifecycleManager.class,
-
TestVfcExternalSystemInfoProvider.class,
TestVfcGrantManager.class,
TestVfcPackageProvider.class,
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java
index a284f28f..457d4688 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTDirectReal.java
@@ -52,50 +52,6 @@ public class CTDirectReal {
public void testBasicWorkflow() throws Exception {
SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
- VimInfo nokia_regionOne = externalSystemInfoProvider.getVimInfo("Nokia_RegionOne");
-
- VnfLifecycleChangeNotification recievedNot = new VnfLifecycleChangeNotification();
- recievedNot.setVnfInstanceId("CBAM-d8deb02a7a51449dba576ac9eabb55b8");
- ReportedAffectedConnectionPoints affectedConnectionPoints = new ReportedAffectedConnectionPoints();
- recievedNot.setAffectedVirtualLinks(new ArrayList<>());
- AffectedVirtualLink link = new AffectedVirtualLink();
- recievedNot.getAffectedVirtualLinks().add(link);
- link.setId("vlid1");
- link.setChangeType(ChangeType.REMOVED);
- link.setVirtualLinkDescId("vldId1");
- link.setResource(new ResourceHandle());
- link.getResource().setResourceId("netProviderId1");
- link.getResource().setAdditionalData(additionalData("name", "networkName"));
- recievedNot.setAffectedVnfcs(new ArrayList<>());
- AffectedVnfc vnfc = new AffectedVnfc();
- vnfc.setId("myVnfcId1");
- vnfc.setChangeType(ChangeType.ADDED);
- vnfc.setVduId("myVduId");
- vnfc.setStorageResourceIds(new ArrayList<>());
- vnfc.setComputeResource(new ResourceHandle());
- vnfc.getComputeResource().setResourceId("serverProvId1");
- JsonObject additionalData = additionalData("name", "serverName");
- additionalData.addProperty("tenantId", "de8fd0d1d5874503a47b920c10f4322a");
- vnfc.getComputeResource().setAdditionalData(additionalData);
- recievedNot.getAffectedVnfcs().add(vnfc);
- ReportedAffectedCp addedCp = new ReportedAffectedCp();
- addedCp.setCpId("cpId");
- addedCp.setIpAddress("1.2.3.4");
- addedCp.setMacAddress("a:b:c:d:e:f");
- addedCp.setNetworkProviderId("netProviderId1");
- addedCp.setServerProviderId("serverProvId1");
- addedCp.setProviderId("portId");
- addedCp.setTenantId("de8fd0d1d5874503a47b920c10f4322a");
- addedCp.setCpdId("cpdId");
- affectedConnectionPoints.getPost().add(addedCp);
- notificationProcessor.processNotification(recievedNot, null, of(affectedConnectionPoints), "Nokia_RegionOne", "vnfmId");
- }
-
- JsonObject additionalData(String key, String value) {
- JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty(key, value);
- return jsonObject;
}
-
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
deleted file mode 100644
index 582b41df..00000000
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so;
-
-import com.google.gson.JsonObject;
-import com.nokia.cbam.lcm.v32.model.ExtVirtualLinkData;
-import com.nokia.cbam.lcm.v32.model.VimSoftwareImage;
-import com.nokia.cbam.lcm.v32.model.VnfInfo;
-import com.nokia.cbam.lcm.v32.model.VnfProperty;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.GenericVnfManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.*;
-import org.onap.vnfmadapter.so.model.*;
-import org.onap.vnfmdriver.model.*;
-
-import static com.nokia.cbam.lcm.v32.model.VimInfo.VimInfoTypeEnum.*;
-import static junit.framework.TestCase.assertEquals;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
-
-public class TestSoLifecycleManager extends TestBase {
-
- private static final String VNFD_ID = "cbamVnfdId";
- @Mock
- private LifecycleManagerForSo lifecycleManager;
- @Mock
- private AAIExternalSystemInfoProvider vimInfoProvider;
- @Mock
- private JobManagerForSo jobManager;
- @Mock
- private GenericVnfManager genericVnfManager;
- private SoLifecycleManager soLifecycleManager;
-
- @Before
- public void init() {
- soLifecycleManager = new SoLifecycleManager(lifecycleManager, vimInfoProvider, cbamRestApiProviderForSo, jobManager, genericVnfManager);
- }
-
- /**
- * test VNF creation
- */
- @Test
- public void testVnfCreation() throws Exception {
- SoVnfCreationRequest onapRequest = new SoVnfCreationRequest();
- Object additionalParams = new JsonObject();
- onapRequest.setAdditionalParams(additionalParams);
- onapRequest.setCsarId("csarId");
- onapRequest.setDescription("description");
- onapRequest.setName("name");
- VnfInfo vnfInfo = new VnfInfo();
- vnfInfo.setId(VNF_ID);
- LifecycleManager.VnfCreationResult genericResponse = new LifecycleManager.VnfCreationResult(vnfInfo, VNFD_ID);
- when(lifecycleManager.create(VNFM_ID, "csarId", "name", "description")).thenReturn(genericResponse);
- //when
- SoVnfCreationResponse response = soLifecycleManager.create(VNFM_ID, onapRequest);
- //verify
- assertEquals(VNF_ID, response.getVnfId());
- }
-
- /**
- * test VNF activation without parameters
- */
- @Test
- public void testVnfActivation() throws Exception {
- SoVnfActivationRequest soRequest = new SoVnfActivationRequest();
- soRequest.setVimId(VIM_ID);
-
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- org.onap.vnfmdriver.model.VnfInfo vnfInfo = new org.onap.vnfmdriver.model.VnfInfo();
- vnfInfo.setVnfdId(VNFD_ID);
- when(lifecycleManager.queryVnf(VNFM_ID, VNF_ID)).thenReturn(vnfInfo);
- ArgumentCaptor<List<ExtVirtualLinkInfo>> extLinks = ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<AdditionalParameters> additionalParameters = ArgumentCaptor.forClass(AdditionalParameters.class);
- VnfInstantiateResponse instantiationResponse = new VnfInstantiateResponse();
- instantiationResponse.setJobId(JOB_ID);
- when(lifecycleManager.instantiate(eq(VNFM_ID), extLinks.capture(), eq(httpResponse), eq(additionalParams), additionalParameters.capture(), eq(VNF_ID), eq("csarId"), eq(VNFD_ID))).thenReturn(instantiationResponse);
- org.onap.vnfmdriver.model.VimInfo esrInfo = new org.onap.vnfmdriver.model.VimInfo();
- esrInfo.setUrl("http://localhost:123/v3");
- esrInfo.setDomain("domain");
- when(vimInfoProvider.getVimInfo(VIM_ID)).thenReturn(esrInfo);
- VnfInfo cbamVnfInfo = new VnfInfo();
- cbamVnfInfo.setExtensions(new ArrayList<>());
- VnfProperty onapVnfdId = new VnfProperty();
- cbamVnfInfo.getExtensions().add(onapVnfdId);
- onapVnfdId.setName(LifecycleManager.ONAP_CSAR_ID);
- onapVnfdId.setValue("csarId");
- when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(cbamVnfInfo));
- //when
- SoJobHandler jobHandler = soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- AdditionalParameters actualAdditionalParameters = additionalParameters.getValue();
- assertEquals(0, actualAdditionalParameters.getComputeResourceFlavours().size());
- assertEquals(additionalParams, actualAdditionalParameters.getAdditionalParams());
- assertEquals(0, actualAdditionalParameters.getExternalConnectionPointAddresses().size());
- assertEquals(0, actualAdditionalParameters.getExtManagedVirtualLinks().size());
- assertEquals(0, actualAdditionalParameters.getExtVirtualLinks().size());
- assertEquals("default", actualAdditionalParameters.getInstantiationLevel());
- assertEquals(0, actualAdditionalParameters.getSoftwareImages().size());
- assertEquals(OPENSTACK_V3_INFO, actualAdditionalParameters.getVimType());
- assertEquals(0, actualAdditionalParameters.getZones().size());
- assertEquals(0, extLinks.getValue().size());
- }
-
-
- /**
- * test VNF activation without parameters for V2 based API
- */
- @Test
- public void testVnfActivationForV2() throws Exception {
- SoVnfActivationRequest soRequest = new SoVnfActivationRequest();
- soRequest.setVimId(VIM_ID);
-
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- org.onap.vnfmdriver.model.VnfInfo vnfInfo = new org.onap.vnfmdriver.model.VnfInfo();
- vnfInfo.setVnfdId(VNFD_ID);
- when(lifecycleManager.queryVnf(VNFM_ID, VNF_ID)).thenReturn(vnfInfo);
- ArgumentCaptor<List<ExtVirtualLinkInfo>> extLinks = ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<AdditionalParameters> additionalParameters = ArgumentCaptor.forClass(AdditionalParameters.class);
- VnfInstantiateResponse instantiationResponse = new VnfInstantiateResponse();
- instantiationResponse.setJobId(JOB_ID);
- when(lifecycleManager.instantiate(eq(VNFM_ID), extLinks.capture(), eq(httpResponse), eq(additionalParams), additionalParameters.capture(), eq(VNF_ID), eq("csarId"), eq(VNFD_ID))).thenReturn(instantiationResponse);
- org.onap.vnfmdriver.model.VimInfo esrInfo = new org.onap.vnfmdriver.model.VimInfo();
- esrInfo.setUrl("http://localhost:123/v2");
- when(vimInfoProvider.getVimInfo(VIM_ID)).thenReturn(esrInfo);
- VnfInfo cbamVnfInfo = new VnfInfo();
- cbamVnfInfo.setExtensions(new ArrayList<>());
- VnfProperty onapVnfdId = new VnfProperty();
- cbamVnfInfo.getExtensions().add(onapVnfdId);
- onapVnfdId.setName(LifecycleManager.ONAP_CSAR_ID);
- onapVnfdId.setValue("csarId");
- when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(cbamVnfInfo));
- //when
- SoJobHandler jobHandler = soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- AdditionalParameters actualAdditionalParameters = additionalParameters.getValue();
- assertEquals(OPENSTACK_V2_INFO, actualAdditionalParameters.getVimType());
- }
-
- /**
- * test VNF activation without parameters for vCloud based API
- */
- @Test
- public void testVnfActivationForVcloud() throws Exception {
- SoVnfActivationRequest soRequest = new SoVnfActivationRequest();
- soRequest.setVimId(VIM_ID);
-
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- org.onap.vnfmdriver.model.VnfInfo vnfInfo = new org.onap.vnfmdriver.model.VnfInfo();
- vnfInfo.setVnfdId(VNFD_ID);
- when(lifecycleManager.queryVnf(VNFM_ID, VNF_ID)).thenReturn(vnfInfo);
- ArgumentCaptor<List<ExtVirtualLinkInfo>> extLinks = ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<AdditionalParameters> additionalParameters = ArgumentCaptor.forClass(AdditionalParameters.class);
- VnfInstantiateResponse instantiationResponse = new VnfInstantiateResponse();
- instantiationResponse.setJobId(JOB_ID);
- when(lifecycleManager.instantiate(eq(VNFM_ID), extLinks.capture(), eq(httpResponse), eq(additionalParams), additionalParameters.capture(), eq(VNF_ID), eq("csarId"), eq(VNFD_ID))).thenReturn(instantiationResponse);
- org.onap.vnfmdriver.model.VimInfo esrInfo = new org.onap.vnfmdriver.model.VimInfo();
- esrInfo.setUrl("http://localhost:123/");
- esrInfo.setDomain("domain");
- when(vimInfoProvider.getVimInfo(VIM_ID)).thenReturn(esrInfo);
- VnfInfo cbamVnfInfo = new VnfInfo();
- cbamVnfInfo.setExtensions(new ArrayList<>());
- VnfProperty onapVnfdId = new VnfProperty();
- cbamVnfInfo.getExtensions().add(onapVnfdId);
- onapVnfdId.setName(LifecycleManager.ONAP_CSAR_ID);
- onapVnfdId.setValue("csarId");
- when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(cbamVnfInfo));
- //when
- SoJobHandler jobHandler = soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- AdditionalParameters actualAdditionalParameters = additionalParameters.getValue();
- assertEquals(VMWARE_VCLOUD_INFO, actualAdditionalParameters.getVimType());
- }
-
- /**
- * test VNF activation with VDU mappings
- */
- @Test
- public void testVnfActivationWithVdu() throws Exception {
- SoVnfActivationRequest soRequest = new SoVnfActivationRequest();
- soRequest.setVimId(VIM_ID);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- org.onap.vnfmdriver.model.VnfInfo vnfInfo = new org.onap.vnfmdriver.model.VnfInfo();
- vnfInfo.setVnfdId(VNFD_ID);
- when(lifecycleManager.queryVnf(VNFM_ID, VNF_ID)).thenReturn(vnfInfo);
- ArgumentCaptor<List<ExtVirtualLinkInfo>> extLinks = ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<AdditionalParameters> additionalParameters = ArgumentCaptor.forClass(AdditionalParameters.class);
- VnfInstantiateResponse instantiationResponse = new VnfInstantiateResponse();
- instantiationResponse.setJobId(JOB_ID);
- when(lifecycleManager.instantiate(eq(VNFM_ID), extLinks.capture(), eq(httpResponse), eq(additionalParams), additionalParameters.capture(), eq(VNF_ID), eq("csarId"), eq(VNFD_ID))).thenReturn(instantiationResponse);
- org.onap.vnfmdriver.model.VimInfo esrInfo = new org.onap.vnfmdriver.model.VimInfo();
- esrInfo.setUrl("http://localhost:123/v3");
- esrInfo.setDomain("domain");
- when(vimInfoProvider.getVimInfo(VIM_ID)).thenReturn(esrInfo);
- VnfInfo cbamVnfInfo = new VnfInfo();
- cbamVnfInfo.setExtensions(new ArrayList<>());
- VnfProperty onapVnfdId = new VnfProperty();
- cbamVnfInfo.getExtensions().add(onapVnfdId);
- onapVnfdId.setName(LifecycleManager.ONAP_CSAR_ID);
- onapVnfdId.setValue("csarId");
- when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(cbamVnfInfo));
- soRequest.setVduMappings(new ArrayList<>());
- SoVduMapping vduMapping = new SoVduMapping();
- soRequest.getVduMappings().add(vduMapping);
- vduMapping.setFlavourId("flavorId");
- vduMapping.setImageId("imageId");
- vduMapping.setVduId("vduId");
- //when
- SoJobHandler jobHandler = soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- AdditionalParameters actualAdditionalParameters = additionalParameters.getValue();
- assertEquals(1, actualAdditionalParameters.getComputeResourceFlavours().size());
- assertEquals(1, actualAdditionalParameters.getSoftwareImages().size());
- VimSoftwareImage image = actualAdditionalParameters.getSoftwareImages().get(0);
- assertEquals(VIM_ID, image.getVimId());
- assertEquals("vduId_image", image.getVnfdSoftwareImageId());
- assertEquals("imageId", image.getResourceId());
- assertEquals(VIM_ID, actualAdditionalParameters.getComputeResourceFlavours().get(0).getVimId());
- assertEquals("flavorId", actualAdditionalParameters.getComputeResourceFlavours().get(0).getResourceId());
- assertEquals("vduId", actualAdditionalParameters.getComputeResourceFlavours().get(0).getVnfdVirtualComputeDescId());
- assertEquals(OPENSTACK_V3_INFO, actualAdditionalParameters.getVimType());
- }
-
- /**
- * test VNF activation with network mappings
- */
- @Test
- public void testVnfActivationWithNetworkMapping() throws Exception {
- SoVnfActivationRequest soRequest = new SoVnfActivationRequest();
- soRequest.setVimId(VIM_ID);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- org.onap.vnfmdriver.model.VnfInfo vnfInfo = new org.onap.vnfmdriver.model.VnfInfo();
- vnfInfo.setVnfdId(VNFD_ID);
- when(lifecycleManager.queryVnf(VNFM_ID, VNF_ID)).thenReturn(vnfInfo);
- ArgumentCaptor<List<ExtVirtualLinkInfo>> extLinks = ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<AdditionalParameters> additionalParameters = ArgumentCaptor.forClass(AdditionalParameters.class);
- VnfInstantiateResponse instantiationResponse = new VnfInstantiateResponse();
- instantiationResponse.setJobId(JOB_ID);
- when(lifecycleManager.instantiate(eq(VNFM_ID), extLinks.capture(), eq(httpResponse), eq(additionalParams), additionalParameters.capture(), eq(VNF_ID), eq("csarId"), eq(VNFD_ID))).thenReturn(instantiationResponse);
- org.onap.vnfmdriver.model.VimInfo esrInfo = new org.onap.vnfmdriver.model.VimInfo();
- esrInfo.setUrl("http://localhost:123/v3");
- esrInfo.setDomain("domain");
- when(vimInfoProvider.getVimInfo(VIM_ID)).thenReturn(esrInfo);
- VnfInfo cbamVnfInfo = new VnfInfo();
- cbamVnfInfo.setExtensions(new ArrayList<>());
- VnfProperty onapVnfdId = new VnfProperty();
- cbamVnfInfo.getExtensions().add(onapVnfdId);
- onapVnfdId.setName(LifecycleManager.ONAP_CSAR_ID);
- onapVnfdId.setValue("csarId");
- when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(cbamVnfInfo));
- soRequest.setNetworkMappings(new ArrayList<>());
- SoNetworkMapping networkMapping = new SoNetworkMapping();
- networkMapping.setVldId("myVldId");
- networkMapping.setNetworkProviderId("providerId");
- networkMapping.setAssignedAddresses(new ArrayList<>());
- SoAssignedAddresses e1 = new SoAssignedAddresses();
- e1.setIpAddress("1.2.3.4");
- e1.setCpdId("cpdId");
- SoAssignedAddresses e2 = new SoAssignedAddresses();
- e2.setIpAddress("1.2.3.5");
- e2.setCpdId("cpdId2");
- SoAssignedAddresses e3 = new SoAssignedAddresses();
- e3.setIpAddress("1.2.3.6");
- e3.setCpdId("cpdId2");
- SoAssignedAddresses e4 = new SoAssignedAddresses();
- e4.setIpAddress("1.2.3.6");
- e4.setCpdId("cpdId2");
- networkMapping.getAssignedAddresses().add(e1);
- networkMapping.getAssignedAddresses().add(e2);
- networkMapping.getAssignedAddresses().add(e3);
- networkMapping.getAssignedAddresses().add(e4);
- SoNetworkMapping networkMapping2 = new SoNetworkMapping();
- soRequest.getNetworkMappings().add(networkMapping);
- soRequest.getNetworkMappings().add(networkMapping2);
- networkMapping2.setVldId("myVldId2");
- networkMapping2.setNetworkProviderId("providerId2");
-
- //when
- SoJobHandler jobHandler = soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- AdditionalParameters actualAdditionalParameters = additionalParameters.getValue();
- assertEquals(2, actualAdditionalParameters.getExtVirtualLinks().size());
- ExtVirtualLinkData actualVl = actualAdditionalParameters.getExtVirtualLinks().get(0);
- assertEquals(VIM_ID, actualVl.getVimId());
- assertEquals("providerId", actualVl.getResourceId());
- assertEquals("myVldId", actualVl.getExtVirtualLinkId());
- assertEquals(2, actualVl.getExtCps().size());
- assertEquals("cpdId", actualVl.getExtCps().get(0).getCpdId());
- assertEquals("1.2.3.4", actualVl.getExtCps().get(0).getAddresses().get(0).getIp());
- assertEquals("cpdId2", actualVl.getExtCps().get(1).getCpdId());
- assertEquals("1.2.3.5", actualVl.getExtCps().get(1).getAddresses().get(0).getIp());
- assertEquals("1.2.3.6", actualVl.getExtCps().get(1).getAddresses().get(1).getIp());
- }
-
- /**
- * test VNF activation with server mappings
- */
- @Test
- public void testVnfActivationWithServerMappings() throws Exception {
- SoVnfActivationRequest soRequest = new SoVnfActivationRequest();
- soRequest.setVimId(VIM_ID);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- org.onap.vnfmdriver.model.VnfInfo vnfInfo = new org.onap.vnfmdriver.model.VnfInfo();
- vnfInfo.setVnfdId(VNFD_ID);
- when(lifecycleManager.queryVnf(VNFM_ID, VNF_ID)).thenReturn(vnfInfo);
- ArgumentCaptor<List<ExtVirtualLinkInfo>> extLinks = ArgumentCaptor.forClass(List.class);
- ArgumentCaptor<AdditionalParameters> additionalParameters = ArgumentCaptor.forClass(AdditionalParameters.class);
- VnfInstantiateResponse instantiationResponse = new VnfInstantiateResponse();
- instantiationResponse.setJobId(JOB_ID);
- when(lifecycleManager.instantiate(eq(VNFM_ID), extLinks.capture(), eq(httpResponse), eq(additionalParams), additionalParameters.capture(), eq(VNF_ID), eq("csarId"), eq(VNFD_ID))).thenReturn(instantiationResponse);
- org.onap.vnfmdriver.model.VimInfo esrInfo = new org.onap.vnfmdriver.model.VimInfo();
- esrInfo.setUrl("http://localhost:123/v3");
- esrInfo.setDomain("domain");
- when(vimInfoProvider.getVimInfo(VIM_ID)).thenReturn(esrInfo);
- VnfInfo cbamVnfInfo = new VnfInfo();
- cbamVnfInfo.setExtensions(new ArrayList<>());
- VnfProperty onapVnfdId = new VnfProperty();
- cbamVnfInfo.getExtensions().add(onapVnfdId);
- onapVnfdId.setName(LifecycleManager.ONAP_CSAR_ID);
- onapVnfdId.setValue("csarId");
- when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(cbamVnfInfo));
- soRequest.setServerMappings(new ArrayList<>());
- SoServerMapping s1 = new SoServerMapping();
- soRequest.getServerMappings().add(s1);
- s1.setVduId("vduId1");
- s1.setAvailabilityZoneId("azId1");
- SoServerMapping s2 = new SoServerMapping();
- soRequest.getServerMappings().add(s2);
- s2.setVduId("vduId1");
- s2.setAvailabilityZoneId("azId1");
- SoServerMapping s3 = new SoServerMapping();
- soRequest.getServerMappings().add(s3);
- s3.setVduId("vduId2");
- s3.setAvailabilityZoneId("azId1");
-
- //when
- SoJobHandler jobHandler = soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- AdditionalParameters actualAdditionalParameters = additionalParameters.getValue();
- assertEquals(2, actualAdditionalParameters.getZones().size());
- assertEquals(VIM_ID, actualAdditionalParameters.getZones().get(0).getVimId());
- assertEquals("azId1", actualAdditionalParameters.getZones().get(0).getResourceId());
- assertEquals("vduId1", actualAdditionalParameters.getZones().get(0).getId());
- assertEquals(VIM_ID, actualAdditionalParameters.getZones().get(1).getVimId());
- assertEquals("azId1", actualAdditionalParameters.getZones().get(1).getResourceId());
- assertEquals("vduId2", actualAdditionalParameters.getZones().get(1).getId());
- }
-
- /**
- * test VNF scale in
- */
- @Test
- public void testScaleIn() throws Exception {
- SoVnfScaleRequest soRequest = new SoVnfScaleRequest();
- ArgumentCaptor<org.onap.vnfmdriver.model.VnfScaleRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfScaleRequest.class);
- JobInfo jobInfo = new JobInfo();
- jobInfo.setJobId(JOB_ID);
-
- soRequest.setAspectId("aspectId");
- soRequest.setDirection(SoScaleDirection.IN);
- soRequest.setSteps(2);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- when(lifecycleManager.scaleVnf(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(httpResponse))).thenReturn(jobInfo);
- //when
- SoJobHandler jobHandler = soLifecycleManager.scale(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- assertEquals(2, Integer.parseInt(driverRequest.getValue().getNumberOfSteps()));
- assertEquals("aspectId", driverRequest.getValue().getAspectId());
- assertEquals(org.onap.vnfmdriver.model.ScaleDirection.IN, driverRequest.getValue().getType());
- assertEquals(additionalParams, driverRequest.getValue().getAdditionalParam());
- }
-
- /**
- * test VNF scale out
- */
- @Test
- public void testScaleOut() throws Exception {
- SoVnfScaleRequest soRequest = new SoVnfScaleRequest();
- ArgumentCaptor<org.onap.vnfmdriver.model.VnfScaleRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfScaleRequest.class);
- JobInfo jobInfo = new JobInfo();
- jobInfo.setJobId(JOB_ID);
-
- soRequest.setAspectId("aspectId");
- soRequest.setDirection(SoScaleDirection.OUT);
- soRequest.setSteps(2);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- when(lifecycleManager.scaleVnf(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(httpResponse))).thenReturn(jobInfo);
- //when
- SoJobHandler jobHandler = soLifecycleManager.scale(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- assertEquals(2, Integer.parseInt(driverRequest.getValue().getNumberOfSteps()));
- assertEquals("aspectId", driverRequest.getValue().getAspectId());
- assertEquals(org.onap.vnfmdriver.model.ScaleDirection.OUT, driverRequest.getValue().getType());
- assertEquals(additionalParams, driverRequest.getValue().getAdditionalParam());
- }
-
- /**
- * test VNF heal
- */
- @Test
- public void testHeal() throws Exception {
- SoVnfHealRequest soRequest = new SoVnfHealRequest();
- ArgumentCaptor<org.onap.vnfmdriver.model.VnfHealRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfHealRequest.class);
- JobInfo jobInfo = new JobInfo();
- jobInfo.setJobId(JOB_ID);
-
- soRequest.setVnfcId(VNF_ID + "_vnfcId");
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- when(lifecycleManager.healVnf(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(Optional.of("vnfcId")), eq(httpResponse))).thenReturn(jobInfo);
- //when
- SoJobHandler jobHandler = soLifecycleManager.heal(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- assertEquals("notUsedByDriver", driverRequest.getValue().getAffectedvm().getVduid());
- assertEquals("notUsedByDriver", driverRequest.getValue().getAffectedvm().getVimid());
- assertEquals("unknown", driverRequest.getValue().getAffectedvm().getVmname());
- assertEquals("heal", driverRequest.getValue().getAction());
- }
-
- /**
- * test VNF deactivation
- */
- @Test
- public void testDeactivation() throws Exception {
- SoVnfTerminationRequest soRequest = new SoVnfTerminationRequest();
- ArgumentCaptor<org.onap.vnfmdriver.model.VnfTerminateRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfTerminateRequest.class);
- JobInfo jobInfo = new JobInfo();
- jobInfo.setJobId(JOB_ID);
- soRequest.setGracefulTerminationTimeoutInMs(1234);
- soRequest.setMode(SoTerminationMode.GRACEFUL);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- when(lifecycleManager.terminateAndDelete(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(httpResponse))).thenReturn(jobInfo);
- //when
- SoJobHandler jobHandler = soLifecycleManager.deactivate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- assertEquals(VnfTerminationType.GRACEFUL, driverRequest.getValue().getTerminationType());
- assertEquals("1234", driverRequest.getValue().getGracefulTerminationTimeout());
- }
-
- /**
- * test VNF deactivation
- */
- @Test
- public void testDeactivationForceFull() throws Exception {
- SoVnfTerminationRequest soRequest = new SoVnfTerminationRequest();
- ArgumentCaptor<org.onap.vnfmdriver.model.VnfTerminateRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfTerminateRequest.class);
- JobInfo jobInfo = new JobInfo();
- jobInfo.setJobId(JOB_ID);
- soRequest.setMode(SoTerminationMode.FORCEFUL);
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- when(lifecycleManager.terminateAndDelete(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(httpResponse))).thenReturn(jobInfo);
- //when
- SoJobHandler jobHandler = soLifecycleManager.deactivate(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- assertEquals(VnfTerminationType.FORCEFUL, driverRequest.getValue().getTerminationType());
- assertEquals(null, driverRequest.getValue().getGracefulTerminationTimeout());
- }
-
- /**
- * test VNF deletion
- */
- @Test
- public void testDelete() throws Exception {
- //when
- soLifecycleManager.delete(VNFM_ID, VNF_ID);
- //verify
- verify(lifecycleManager).deleteVnf(VNFM_ID, VNF_ID);
- }
-
- /**
- * test VNF custom operation
- */
- @Test
- public void testCustomOperation() throws Exception {
- SoVnfCustomOperation soRequest = new SoVnfCustomOperation();
- JobInfo jobInfo = new JobInfo();
- jobInfo.setJobId(JOB_ID);
- soRequest.setOperationId("operationId");
- JsonObject additionalParams = new JsonObject();
- soRequest.setAdditionalParams(additionalParams);
- when(lifecycleManager.customOperation(VNFM_ID, VNF_ID, "operationId", additionalParams, httpResponse)).thenReturn(jobInfo);
- //when
- SoJobHandler jobHandler = soLifecycleManager.customOperation(VNFM_ID, VNF_ID, soRequest, httpResponse);
- //verify
- assertEquals(JOB_ID, jobHandler.getJobId());
- }
-
-
- /**
- * test VNF custom operation
- */
- @Test
- public void testJobDetails() throws Exception {
- JobDetailInfo currentJobDetails = new JobDetailInfo();
- currentJobDetails.setJobId(JOB_ID);
- when(jobManager.getJob(VNFM_ID, JOB_ID)).thenReturn(currentJobDetails);
- currentJobDetails.setResponseDescriptor(new JobDetailInfoResponseDescriptor());
-
- assertJob(currentJobDetails, SoJobStatus.FINISHED, JobStatus.FINISHED);
- assertJob(currentJobDetails, SoJobStatus.FAILED, JobStatus.ERROR);
- assertJob(currentJobDetails, SoJobStatus.FAILED, JobStatus.TIMEOUT);
- assertJob(currentJobDetails, SoJobStatus.STARTED, JobStatus.STARTED);
- assertJob(currentJobDetails, SoJobStatus.STARTED, JobStatus.PROCESSING);
-
- }
-
- private void assertJob(JobDetailInfo currentJobDetails, SoJobStatus expectedState, JobStatus started) {
- currentJobDetails.getResponseDescriptor().setStatus(started);
- //when
- SoJobDetail jobDetail = soLifecycleManager.getJobDetails(VNFM_ID, JOB_ID);
- //verify
- assertEquals(JOB_ID, jobDetail.getJobId());
- assertEquals(expectedState, jobDetail.getStatus());
- }
-
-
-} \ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestCbamVnfdBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestCbamVnfdBuilder.java
index 5840ef4e..10a5a38c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestCbamVnfdBuilder.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestCbamVnfdBuilder.java
@@ -26,7 +26,7 @@ public class TestCbamVnfdBuilder extends TestBase {
private CbamVnfdBuilder packageTransformer = new CbamVnfdBuilder();
/**
- * test package conversion on the most mininal VNFD possible
+ * test package conversion on the most minimal VNFD possible
*/
@Test
public void testEmpty() throws Exception {
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java
index d2a92556..78a8a725 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java
@@ -60,7 +60,7 @@ public class TestOnapVnfPackageBuilder extends TestBase {
}
/**
- * Test conversion for V1 package
+ * Test conversion for V1TOSCA package
*/
@Test
public void testConversionViaV1() throws Exception {
@@ -73,7 +73,7 @@ public class TestOnapVnfPackageBuilder extends TestBase {
String cbamVnfd = new String(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip.vnfd"));
String expectedOnapVnfd = new OnapR1VnfdBuilder().toOnapVnfd(cbamVnfd);
//when
- byte[] convertedPackage = new OnapVnfPackageBuilder().covert(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")), SupportedOnapPackageVersions.V1);
+ byte[] convertedPackage = new OnapVnfPackageBuilder().covert(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")), SupportedOnapPackageVersions.V1TOSCA);
//verify
assertFileInZip(convertedPackage, "TOSCA-Metadata/TOSCA.meta", TestUtil.loadFile("TOSCA.meta"));
assertFileInZip(convertedPackage, "MainServiceTemplate.yaml", expectedOnapVnfd.getBytes());
@@ -84,7 +84,7 @@ public class TestOnapVnfPackageBuilder extends TestBase {
}
/**
- * Test conversion for V2 package
+ * Test conversion for V2TOSCA package
*/
@Test
public void testConversionViaV2() throws Exception {
@@ -97,7 +97,7 @@ public class TestOnapVnfPackageBuilder extends TestBase {
String cbamVnfd = new String(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip.vnfd"));
String expectedOnapVnfd = new OnapR2VnfdBuilder().toOnapVnfd(cbamVnfd);
//when
- byte[] convertedPackage = new OnapVnfPackageBuilder().covert(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")), SupportedOnapPackageVersions.V2);
+ byte[] convertedPackage = new OnapVnfPackageBuilder().covert(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")), SupportedOnapPackageVersions.V2TOSCA);
//verify
assertFileInZip(convertedPackage, "TOSCA-Metadata/TOSCA.meta", TestUtil.loadFile("TOSCA.meta"));
assertFileInZip(convertedPackage, "MainServiceTemplate.yaml", expectedOnapVnfd.getBytes());
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
index 99fd203a..ba64b924 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
@@ -75,7 +75,7 @@ public class TestConverterApi extends TestBase {
when(httpRequest.getPart("fileToUpload")).thenReturn(part);
Part part2 = Mockito.mock(Part.class);
when(httpRequest.getPart("version")).thenReturn(part2);
- when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
+ when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1TOSCA".getBytes()));
//when
converterApi.convert(httpResponse, httpRequest);
//verify
@@ -122,7 +122,7 @@ public class TestConverterApi extends TestBase {
when(httpRequest.getPart("fileToUpload")).thenThrow(expectedException);
Part part = Mockito.mock(Part.class);
when(httpRequest.getPart("version")).thenReturn(part);
- when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
+ when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1TOSCA".getBytes()));
try {
converterApi.convert(httpResponse, httpRequest);
fail();
@@ -143,7 +143,7 @@ public class TestConverterApi extends TestBase {
when(part.getInputStream()).thenReturn(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")));
when(httpRequest.getPart("fileToUpload")).thenReturn(part);
when(httpRequest.getPart("version")).thenThrow(expectedException);
- when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
+ when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1TOSCA".getBytes()));
try {
converterApi.convert(httpResponse, httpRequest);
fail();
@@ -165,7 +165,7 @@ public class TestConverterApi extends TestBase {
Part part2 = Mockito.mock(Part.class);
when(httpRequest.getPart("version")).thenReturn(part2);
- when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
+ when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1TOSCA".getBytes()));
try {
converterApi.convert(httpResponse, httpRequest);
fail();
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java
deleted file mode 100644
index be1ee5a7..00000000
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
-
-import junit.framework.TestCase;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so.SoLifecycleManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
-import org.onap.vnfmadapter.so.model.*;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.springframework.test.util.ReflectionTestUtils.setField;
-
-
-public class TestSoApi extends TestBase {
-
- @Mock
- private SoLifecycleManager soLifecycleManager;
- @InjectMocks
- private SoApi soApi;
- @Mock
- private SoJobHandler jobHandler;
-
- @Before
- public void initMocks() throws Exception {
- setField(SoApi.class, "logger", logger);
- }
-
- /**
- * test create
- */
- @Test
- public void testCreate() {
- SoVnfCreationRequest soRequest = Mockito.mock(SoVnfCreationRequest.class);
- SoVnfCreationResponse vnf = new SoVnfCreationResponse();
- when(soLifecycleManager.create(VNFM_ID, soRequest)).thenReturn(vnf);
- //when
- SoVnfCreationResponse actual = soApi.createVnf(soRequest, VNFM_ID, httpResponse);
- //verify
- verify(logger).info("REST: Create the VNF");
- TestCase.assertEquals(vnf, actual);
- }
-
- /**
- * test activation
- */
- @Test
- public void testActivate() {
- SoVnfActivationRequest soRequest = Mockito.mock(SoVnfActivationRequest.class);
- when(soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
- //when
- SoJobHandler soJobHandler = soApi.activateVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
- //verify
- verify(logger).info("REST: Activate the VNF");
- TestCase.assertEquals(jobHandler, soJobHandler);
- }
-
- /**
- * test scale
- */
- @Test
- public void testScale() {
- SoVnfScaleRequest soRequest = Mockito.mock(SoVnfScaleRequest.class);
- when(soLifecycleManager.scale(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
- //when
- SoJobHandler soJobHandler = soApi.scaleVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
- //verify
- verify(logger).info("REST: Scale the VNF");
- TestCase.assertEquals(jobHandler, soJobHandler);
- }
-
- /**
- * test heal
- */
- @Test
- public void testHeal() {
- SoVnfHealRequest soRequest = Mockito.mock(SoVnfHealRequest.class);
- when(soLifecycleManager.heal(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
- //when
- SoJobHandler soJobHandler = soApi.healVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
- //verify
- verify(logger).info("REST: Heal the VNF");
- TestCase.assertEquals(jobHandler, soJobHandler);
- }
-
-
- /**
- * test custom
- */
- @Test
- public void testCustom() {
- SoVnfCustomOperation soRequest = Mockito.mock(SoVnfCustomOperation.class);
- when(soLifecycleManager.customOperation(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
- //when
- SoJobHandler soJobHandler = soApi.executeCustomOperation(soRequest, VNFM_ID, VNF_ID, httpResponse);
- //verify
- verify(logger).info("REST: Execute custom operation on the VNF");
- TestCase.assertEquals(jobHandler, soJobHandler);
- }
-
- /**
- * test deactivation
- */
- @Test
- public void testDeactivation() {
- SoVnfTerminationRequest soRequest = Mockito.mock(SoVnfTerminationRequest.class);
- when(soLifecycleManager.deactivate(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
- //when
- SoJobHandler soJobHandler = soApi.deactivateVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
- //verify
- verify(logger).info("REST: Deactivate the VNF");
- TestCase.assertEquals(jobHandler, soJobHandler);
- }
-
- /**
- * test delete
- */
- @Test
- public void testDelete() {
- //when
- soApi.deleteVnf(VNFM_ID, VNF_ID, httpResponse);
- //verify
- verify(logger).info("REST: Delete the VNF");
- verify(soLifecycleManager).delete(VNFM_ID, VNF_ID);
- }
-
- /**
- * test deactivation
- */
- @Test
- public void testGetJob() {
- SoJobDetail jobDetail = new SoJobDetail();
- when(soLifecycleManager.getJobDetails(VNFM_ID, JOB_ID)).thenReturn(jobDetail);
- //when
- SoJobDetail actial = soApi.getJob(VNFM_ID, JOB_ID, httpResponse);
- //verify
- verify(logger).trace("REST: Query the job");
- TestCase.assertEquals(jobDetail, actial);
- }
-
-}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerDefinitionConsistency.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerDefinitionConsistency.java
index d39a1445..77406c24 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerDefinitionConsistency.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSwaggerDefinitionConsistency.java
@@ -37,7 +37,7 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil.loadFile;
public class TestSwaggerDefinitionConsistency extends TestBase {
- public static final HashSet<Class<?>> CLASSES = Sets.newHashSet(LcmApi.class, LcnApi.class, SwaggerApi.class, ConverterApi.class, SoApi.class);
+ public static final HashSet<Class<?>> CLASSES = Sets.newHashSet(LcmApi.class, LcnApi.class, SwaggerApi.class, ConverterApi.class, SoV2Api.class);
@Test
public void test() throws Exception {
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
index ea379e67..0ece0080 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
@@ -288,30 +288,7 @@ public class TestLifecycleManager extends TestBase {
}
/**
- * invalid VIM type results in failure
- */
- @Test
- public void testInstantiationWithInvalidVimType() throws Exception {
- //given
- VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO, false);
- when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
- when(logger.isInfoEnabled()).thenReturn(false);
- //when
- try {
- lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
- //verify
- fail();
- } catch (Exception e) {
- assertEquals("Only OPENSTACK_V2_INFO, OPENSTACK_V3_INFO and VMWARE_VCLOUD_INFO is the supported VIM types", e.getMessage());
- }
- verify(vnfApi, never()).vnfsPost(Mockito.any(), Mockito.any());
- verify(logger, never()).info(eq("Starting {} operation on VNF with {} identifier with {} parameter"), eq("creation"), eq("not yet specified"), anyString());
- verify(logger, never()).info(eq("Starting {} operation on VNF with {} identifier with {} parameter"), eq("instantiation"), eq(VNF_ID), anyString());
- verify(logger).error("Only OPENSTACK_V2_INFO, OPENSTACK_V3_INFO and VMWARE_VCLOUD_INFO is the supported VIM types");
- }
-
- /**
- * test instantiation with KeyStone V2 based with SSL
+ * test instantiation with KeyStone V2TOSCA based with SSL
*/
@Test
public void testInstantiationV2WithSsl() throws Exception {
@@ -579,70 +556,6 @@ public class TestLifecycleManager extends TestBase {
}
/**
- * verify backward compatibility with Amsterdam release
- */
- @Test
- public void testInstantiationV3WithNoDomain() throws Exception {
- additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
- additionalParam.setDomain("myDomain");
- VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
- vimInfo.setDomain(null);
- when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
- when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
- grantResponse.setVimId(VIM_ID);
- GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
- accessInfo.setTenant(TENANT);
- vimInfo.setSslInsecure(null);
- grantResponse.setAccessInfo(accessInfo);
- ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
- when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
- //when
- VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
- waitForJobToFinishInJobManager(finished);
- assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
- //verify
- OPENSTACKV3INFO actualVim = (OPENSTACKV3INFO) actualInstantiationRequest.getValue().getVims().get(0);
- assertEquals(VIM_ID, actualVim.getId());
- assertEquals(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, actualVim.getVimInfoType());
- assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint());
- //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates());
- assertEquals("vimPassword", actualVim.getAccessInfo().getPassword());
- assertEquals("regionId", actualVim.getAccessInfo().getRegion());
- assertEquals("myTenant", actualVim.getAccessInfo().getProject());
- assertEquals("myDomain", actualVim.getAccessInfo().getDomain());
- assertEquals("vimUsername", actualVim.getAccessInfo().getUsername());
- assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification());
- assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
- verify(logger).warn("Setting domain from additional parameters");
- }
-
- /**
- * verify backward compatibility with Amsterdam release
- * if no domain is specified error is propagated
- */
- @Test
- public void testInstantiationV3WithNoDomainFail() throws Exception {
- VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
- vimInfo.setDomain(null);
- when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
- additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
- when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
- grantResponse.setVimId(VIM_ID);
- GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
- accessInfo.setTenant(TENANT);
- vimInfo.setSslInsecure(null);
- grantResponse.setAccessInfo(accessInfo);
- ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
- when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
- //when
- VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
- waitForJobToFinishInJobManager(finished);
- assertEquals(0, actualInstantiationRequest.getAllValues().size());
- //verify
- verify(logger).error("The cloud did not supply the cloud domain (Amsterdam release) and was not supplied as additional data");
- }
-
- /**
* test instantiation with vcloud
*/
@Test
@@ -1709,17 +1622,15 @@ public class TestLifecycleManager extends TestBase {
additionalParam.setInstantiationLevel("level1");
switch (cloudType) {
case OPENSTACK_V2_INFO:
- additionalParam.setVimType(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+ vimInfo.setType("openstack");
break;
case OPENSTACK_V3_INFO:
- additionalParam.setVimType(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+ vimInfo.setType("openstack");
vimInfo.setDomain("myDomain");
break;
case VMWARE_VCLOUD_INFO:
- additionalParam.setVimType(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO);
+ vimInfo.setType("vmware");
break;
- default:
- additionalParam.setVimType(VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO);
}
Map<String, List<NetworkAddress>> exteranalConnectionPointAddresses = new HashMap<>();
diff --git a/nokiav2/driver/src/test/resources/application-direct.properties b/nokiav2/driver/src/test/resources/application-direct.properties
index b9c1c68c..9134f642 100644
--- a/nokiav2/driver/src/test/resources/application-direct.properties
+++ b/nokiav2/driver/src/test/resources/application-direct.properties
@@ -61,6 +61,8 @@ sdcPassword=SDC
###############################################################################
# End of mandatory properties for driver #
###############################################################################
+skipLcnSubscription=true
+skipSelfRegistration=true
ipMap=10.0.14.1->msb.api.simpledemo.onap.org,172.17.0.15->msb.api.simpledemo.onap.org,10.0.1.1->aai.api.simpledemo.onap.org
vnfmInfoCacheEvictionInMs=600000
## for logging begin ##
diff --git a/nokiav2/driver/src/test/resources/application.properties b/nokiav2/driver/src/test/resources/application.properties
index d2732910..29da7577 100644
--- a/nokiav2/driver/src/test/resources/application.properties
+++ b/nokiav2/driver/src/test/resources/application.properties
@@ -61,6 +61,8 @@ sdcPassword=SDC
###############################################################################
# End of mandatory properties for driver #
###############################################################################
+skipLcnSubscription=false
+skipSelfRegistration=false
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
vnfmInfoCacheEvictionInMs=600000
## for logging begin ##
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.modified.vnfd.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.modified.vnfd.yaml
index f9fe6a25..53fbdba0 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.modified.vnfd.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.modified.vnfd.yaml
@@ -11,6 +11,11 @@ topology_template:
onapCsarId: {default: kuku}
externalVnfmId: {default: kuku}
vimId: {default: kuku}
+ deployment_flavour:
+ properties:
+ scaling_aspects:
+ aspect1: {max_scale_level: 2}
+ aspect2: {max_scale_level: 3}
interfaces:
Basic:
instantiate:
@@ -67,3 +72,37 @@ topology_template:
include: [javascript/cbam.collectConnectionPoints.js]
output: operation_result
additional_parameters: {jobId: kuku}
+ policies:
+ - b: {type: x}
+ - heat_mapping:
+ type: tosca.policies.nfv.HeatMapping
+ properties:
+ static:
+ virtualLinks: {net1: path, net2: path}
+ vdus:
+ vdu1:
+ - {heatResource: path}
+ vdu2:
+ - {heatResource: path}
+ externalConnectionPoints:
+ ecp1: [path]
+ ecp2: [path]
+ aspects:
+ aspect1:
+ vdus:
+ vdu1:
+ - heatResource: any
+ connectionPoints: {cp1: nic_0, cp2: nic_1}
+ virtualStorages: {disk1: disk_0, disk2: disk_1}
+ vdu2:
+ - {heatResource: any}
+ - {heatResource: any}
+ externalConnectionPoints:
+ ecp1: [path]
+ ecp2: [path]
+ aspect2:
+ vdus:
+ vdu2:
+ - {heatResource: any}
+ externalConnectionPoints:
+ ecp2: [path]
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.original.vnfd.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.original.vnfd.yaml
index 42569b04..dbe57d0b 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.original.vnfd.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.full.original.vnfd.yaml
@@ -10,6 +10,13 @@ topology_template:
extensions:
existingAttribute:
default: "value"
+ deployment_flavour:
+ properties:
+ scaling_aspects:
+ aspect1:
+ max_scale_level: 2
+ aspect2:
+ max_scale_level: 3
interfaces:
Basic:
instantiate:
@@ -30,4 +37,50 @@ topology_template:
scale:
Healable:
heal:
+ policies:
+ - b:
+ type: x
+ - heat_mapping:
+ type: tosca.policies.nfv.HeatMapping
+ properties:
+ static:
+ virtualLinks:
+ net1: path
+ net2: path
+ vdus:
+ vdu1:
+ - heatResource: path
+ vdu2:
+ - heatResource: path
+ externalConnectionPoints:
+ ecp1:
+ - path
+ ecp2:
+ - path
+ aspects:
+ aspect1:
+ vdus:
+ vdu1:
+ - heatResource: any
+ connectionPoints:
+ cp1: nic_0
+ cp2: nic_1
+ virtualStorages:
+ disk1: disk_0
+ disk2: disk_1
+ vdu2:
+ - heatResource: any
+ - heatResource: any
+ externalConnectionPoints:
+ ecp1:
+ - path
+ ecp2:
+ - path
+ aspect2:
+ vdus:
+ vdu2:
+ - heatResource: any
+ externalConnectionPoints:
+ ecp2:
+ - path
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.modified.vnfd.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.modified.vnfd.yaml
index 256aa9ee..f16f34a9 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.modified.vnfd.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.modified.vnfd.yaml
@@ -2,6 +2,15 @@ tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0_nokia
topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF
+ capabilities:
+ deployment_flavour: {}
+ vnf:
+ properties:
+ modifiable_attributes:
+ extensions:
+ onapCsarId: {default: kuku}
+ externalVnfmId: {default: kuku}
+ vimId: {default: kuku}
interfaces:
Basic:
instantiate:
@@ -28,11 +37,3 @@ topology_template:
include: [javascript/cbam.collectConnectionPoints.js]
output: operation_result
additional_parameters: {jobId: kuku}
- capabilities:
- vnf:
- properties:
- modifiable_attributes:
- extensions:
- onapCsarId: {default: kuku}
- externalVnfmId: {default: kuku}
- vimId: {default: kuku}
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.original.vnfd.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.original.vnfd.yaml
index 7709793c..057eddae 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.original.vnfd.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/cbam.minimal.original.vnfd.yaml
@@ -3,6 +3,9 @@ tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0_nokia
topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF
+ capabilities:
+ deployment_flavour:
+ properties:
interfaces:
Basic:
instantiate:
diff --git a/nokiav2/driverwar/pom.xml b/nokiav2/driverwar/pom.xml
index af8d420c..10f12e0a 100644
--- a/nokiav2/driverwar/pom.xml
+++ b/nokiav2/driverwar/pom.xml
@@ -18,14 +18,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>driverwar</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${driver.version}</version>
<packaging>war</packaging>
<name>vfc/nfvo/driver/vnfm/svnfm/nokiav2/driverwar</name>
<description>svnfm vnfm driver</description>
<parent>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -36,7 +36,7 @@
<dependency>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>driver</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${driver.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/nokiav2/generatedapis/pom.xml b/nokiav2/generatedapis/pom.xml
index aa2df37d..9b953d1a 100644
--- a/nokiav2/generatedapis/pom.xml
+++ b/nokiav2/generatedapis/pom.xml
@@ -18,12 +18,12 @@
<parent>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2-clients</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>${driver.version}</version>
<packaging>jar</packaging>
<name>vfc/nfvo/driver/vnfm/svnfm/nokiav2/generatedapis</name>
<properties>
@@ -93,6 +93,27 @@ Release AAI
</configuration>
</execution>
<execution>
+ <id>sov2</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <inputSpec>${basedir}/src/main/resources/so.vnfm.v2.json</inputSpec>
+ <language>java</language>
+ <library>retrofit2</library>
+ <output>${project.build.directory}/generated-sources/sov2</output>
+ <apiPackage>org.onap.vnfmadapter.so.v2.api</apiPackage>
+ <modelPackage>org.onap.vnfmadapter.so.v2.model</modelPackage>
+ <configOptions>
+ <jackson>true</jackson>
+ <sourceFolder>src/gen/java/main</sourceFolder>
+ <withXml>true</withXml>
+ <useRxJava2>true</useRxJava2>
+ </configOptions>
+ </configuration>
+ </execution>
+<!--
+ <execution>
<id>so</id>
<goals>
<goal>generate</goal>
@@ -112,6 +133,7 @@ Release AAI
</configOptions>
</configuration>
</execution>
+-->
<execution>
<id>msb</id>
<goals>
diff --git a/nokiav2/generatedapis/src/main/resources/so.vnfm.json b/nokiav2/generatedapis/src/main/resources/so.vnfm.json
deleted file mode 100644
index c70a83bf..00000000
--- a/nokiav2/generatedapis/src/main/resources/so.vnfm.json
+++ /dev/null
@@ -1,679 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "ONAP SO VNFM Adapter API",
- "description": "Describes the API between SO and the adapter for VNFM",
- "contact": {
- "name": "ONAP SO VNFM",
- "email": "onap-discuss@lists.onap.org",
- "url": "https://gerrit.onap.org/r/#/admin/projects/vfc/nfvo/lcm"
- }
- },
- "basePath": "/api/v1",
- "schemes": [
- "http",
- "https"
- ],
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "paths": {
- "/so/{vnfmId}/vnfs": {
- "post": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "VNF create",
- "description": "VNF create",
- "operationId": "vnf_create",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "in": "body",
- "name": "body",
- "description": "VNF creation request parameter",
- "required": true,
- "schema": {
- "$ref": "#/definitions/SoVnfCreationRequest"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoVnfCreationResponse"
- }
- }
- }
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}": {
- "post": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "VNF activation",
- "description": "VNF activation",
- "operationId": "vnf_activate",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
- },
- {
- "in": "body",
- "name": "body",
- "description": "instantiate request param",
- "required": true,
- "schema": {
- "$ref": "#/definitions/SoVnfActivationRequest"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
- }
- }
- },
- "delete": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "Deletes VNF",
- "description": "Deletes the VNF. If the VNF was instantiated VNF termination must be called before VNF deletion",
- "operationId": "delete_vnf",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
- }
- ],
- "responses": {
- "204": {
- "description": "The VNF was deleted successfully"
- }
- }
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/scale": {
- "post": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "VNF scale",
- "description": "VNF scale request",
- "operationId": "vnf_scale",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
- },
- {
- "in": "body",
- "name": "body",
- "description": "VNF scale request parameters",
- "required": true,
- "schema": {
- "$ref": "#/definitions/SoVnfScaleRequest"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
- }
- }
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/customOperation": {
- "post": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "VNF scale",
- "description": "VNF scale request",
- "operationId": "vnf_scale",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
- },
- {
- "in": "body",
- "name": "body",
- "description": "VNF scale request parameters",
- "required": true,
- "schema": {
- "$ref": "#/definitions/SoVnfCustomOperation"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
- }
- }
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/heal": {
- "post": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "VNF heal",
- "description": "VNF heal",
- "operationId": "vnf_heal",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
- },
- {
- "in": "body",
- "name": "body",
- "description": "VNF heal request parameters",
- "required": true,
- "schema": {
- "$ref": "#/definitions/SoVnfHealRequest"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
- }
- }
- }
- },
- "/so/{vnfmId}/vnfs/{vnfId}/terminate": {
- "post": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "VNF terminate",
- "description": "VNF terminate",
- "operationId": "vnf_terminate",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNF in A&AI",
- "name": "vnfId",
- "in": "path"
- },
- {
- "in": "body",
- "name": "body",
- "description": "VNF termination request parameters",
- "required": true,
- "schema": {
- "$ref": "#/definitions/SoVnfTerminationRequest"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/SoJobHandler"
- }
- }
- }
- }
- },
- "/so/{vnfmId}/jobs/{jobId}": {
- "get": {
- "tags": [
- "SO VNFM Adaptor"
- ],
- "summary": "Query job status",
- "description": "Query the job status",
- "operationId": "get_jobstatus",
- "parameters": [
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the VNFM in A&AI",
- "name": "vnfmId",
- "in": "path"
- },
- {
- "required": true,
- "type": "string",
- "description": "The identifier of the job",
- "name": "jobId",
- "in": "path"
- }
- ],
- "responses": {
- "202": {
- "description": "The details of a job",
- "schema": {
- "$ref": "#/definitions/SoJobDetail"
- }
- },
- "404": {
- "description": "The job is unknown to the VNFM. The VNFM does not keep finished jobs for forever.",
- "schema": {
- "$ref": "#/definitions/SoJobDetail"
- }
- }
- }
- }
- }
- },
- "definitions": {
- "SoJobHandler": {
- "type": "object",
- "properties": {
- "jobId": {
- "required": true,
- "description": "The identifier of the job",
- "type": "string"
- }
- }
- },
- "SoJobStatus": {
- "description": "The status of the job",
- "type": "string",
- "enum": [
- "started",
- "finished",
- "failed"
- ]
- },
- "SoJobDetail": {
- "allOf": [
- {
- "$ref": "#/definitions/SoJobHandler"
- },
- {
- "type": "object",
- "properties": {
- "status": {
- "required": true,
- "description": "The status of the job",
- "$ref": "#/definitions/SoJobStatus"
- },
- "description": {
- "required": true,
- "description": "The description of the current state of the job",
- "type": "string"
- }
- }
- }
- ]
- },
- "SoVnfCreationRequest": {
- "type": "object",
- "properties": {
- "name": {
- "required": true,
- "description": "The name of the VNF",
- "type": "string"
- },
- "csarId": {
- "required": true,
- "description": "The identifier of the VNF package in SDC",
- "type": "string"
- },
- "nsId": {
- "required": false,
- "description": "The identifier of the NS in AAI",
- "type": "string"
- },
- "description": {
- "required": false,
- "description": "The description of the VNF",
- "type": "string"
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoVnfCreationResponse": {
- "type": "object",
- "properties": {
- "vnfId": {
- "required": true,
- "description": "The identifier of the created VNF",
- "type": "string"
- }
- }
- },
- "SoVduMapping": {
- "type": "object",
- "properties": {
- "vduId": {
- "required": true,
- "description": "The identifier of the VDU within the VNF package",
- "type": "string"
- },
- "imageId": {
- "required": true,
- "description": "The provider id of the image to be used for the VDU",
- "type": "string"
- },
- "flavourId": {
- "required": true,
- "description": "The provider id of the flavour to be used for the VDU",
- "type": "string"
- }
- }
- },
- "SoServerMapping": {
- "type": "object",
- "description": "Maps a server instance to a VDU and availability zone",
- "properties": {
- "vduId": {
- "required": true,
- "description": "The identifier of the VDU",
- "type": "string"
- },
- "availabilityZoneId": {
- "required": false,
- "description": "The provider id of the availability zone to be used for the server instance",
- "type": "string"
- }
- }
- },
- "SoAssignedAddresses": {
- "type": "object",
- "properties": {
- "cpdId" : {
- "required": true,
- "description": "The identifier of the connection point descriptor",
- "type" : "string"
- },
- "ipAddress": {
- "required": true,
- "description": "The IP address to be used",
- "type": "string"
- }
- }
- },
- "SoNetworkMapping": {
- "type": "object",
- "properties": {
- "vldId": {
- "required": true,
- "description": "The identifier of the network in the VNF package",
- "type": "string"
- },
- "networkProviderId": {
- "required": true,
- "description": "The provider id of the network be used for the given purpose",
- "type": "string"
- },
- "assignedAddresses": {
- "required": true,
- "description": "The assigned network addresses",
- "type" : "array",
- "items": {
- "$ref": "#/definitions/SoAssignedAddresses"
- }
- }
- }
- },
- "SoVnfActivationRequest": {
- "type": "object",
- "properties": {
- "vimId" : {
- "required" : true,
- "type" : "string",
- "description" : "The identifier of the VIM on which the VNF is to be instantiated"
- },
- "serverMappings": {
- "required": true,
- "description": "The server mappings",
- "type" : "array",
- "items": {
- "$ref": "#/definitions/SoServerMapping"
- }
- },
- "vduMappings": {
- "required": true,
- "description": "The VDU mappings",
- "type" : "array",
- "items": {
- "$ref": "#/definitions/SoVduMapping"
- }
- },
- "networkMappings": {
- "required": true,
- "description": "The network mappings",
- "type" : "array",
- "items": {
- "$ref": "#/definitions/SoNetworkMapping"
- }
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoScaleDirection": {
- "description": "The direction of the scale",
- "type": "string",
- "enum": [
- "in",
- "out"
- ]
- },
- "SoVnfScaleRequest": {
- "type": "object",
- "properties": {
- "aspectId": {
- "type": "string",
- "description": "The identifier of the scaling aspect in the VNF package"
- },
- "steps": {
- "type": "integer",
- "description": "The expected absolute scale level"
- },
- "direction": {
- "required": true,
- "description": "The direction of the scale",
- "$ref": "#/definitions/SoScaleDirection"
- },
- "serverMappings": {
- "required": true,
- "description": "The server mappings",
- "items": {
- "$ref": "#/definitions/SoServerMapping"
- }
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoVnfCustomOperation": {
- "type": "object",
- "properties": {
- "operationId": {
- "required" : true,
- "type": "string",
- "description": "The identifier of the custom operation"
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoVnfHealRequest": {
- "type": "object",
- "properties": {
- "vnfcId": {
- "type": "string",
- "description": "The identifier of the VNFC to be healed"
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- },
- "SoTerminationMode": {
- "description": "The way in which the VNF is terminated",
- "type": "string",
- "enum": [
- "forceful",
- "graceful"
- ]
- },
- "SoVnfTerminationRequest": {
- "type": "object",
- "properties": {
- "mode" : {
- "required" : true,
- "description" : "The VNF termination mode",
- "$ref": "#/definitions/SoTerminationMode"
- },
- "gracefulTerminationTimeoutInMs": {
- "required" : false,
- "type": "integer",
- "description": "The timeout for graceful termination. After the timeout has expired forceful termination is attempted."
- },
- "additionalParams": {
- "description": "Additional VNFM specific parameters",
- "type": "object",
- "additionalProperties": true
- }
- }
- }
- }
-}
diff --git a/nokiav2/generatedapis/src/main/resources/so.vnfm.v2.json b/nokiav2/generatedapis/src/main/resources/so.vnfm.v2.json
new file mode 100644
index 00000000..248eb92a
--- /dev/null
+++ b/nokiav2/generatedapis/src/main/resources/so.vnfm.v2.json
@@ -0,0 +1,616 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "version": "2.0.0",
+ "title": "ONAP SO VNFM Adapter API v2",
+ "description": "Describes the API between SO and the adapter for VNFM",
+ "contact": {
+ "name": "ONAP SO VNFM",
+ "email": "onap-discuss@lists.onap.org",
+ "url": "https://gerrit.onap.org/r/#/admin/projects/vfc/nfvo/lcm"
+ }
+ },
+ "basePath": "/api/v1",
+ "schemes": [
+ "http",
+ "https"
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "paths": {
+ "/so/v2/ping": {
+ "get": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "Test VNFM driver health",
+ "description": "Test VNFM driver health",
+ "responses": {
+ "204": {
+ "description": "VNFM adapter is healthy"
+ }
+ }
+ }
+ },
+ "/so/v2/vnfs/{vnfIdInAai}/rollback": {
+ "post": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "Rollback VNF update operation",
+ "description": "Rollback VNF update operation",
+ "operationId": "rollback",
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "Rollback parameters",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2RollbackVnfUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Operation has been rolled back"
+ }
+ }
+ }
+ },
+ "/so/v2/vnfs/{vnfIdInAai}": {
+ "get": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VNF query",
+ "description": "VNF query",
+ "operationId": "vnf_query",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VNF in A&AI.",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF creation query parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfQueryRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "",
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfQueryResponse"
+ }
+ },
+ "404": {
+ "descriotion": "The VNF does not exist on the VNFM side"
+ }
+ }
+ },
+ "post": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VNF create",
+ "description": "VNF create",
+ "operationId": "vnf_create",
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF creation query parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfCreateRequest"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "The VNF was created on the VNFM side."
+ },
+ "400": {
+ "description": "The VNF could not be instantiated on the VNFM side. Failure has been treated according to deleteUponFailure parameter"
+ }
+ }
+ },
+ "put": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VNF update",
+ "description": "VNF update",
+ "operationId": "vnf_update",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF update parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfUpdateRequest"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The VNF update has finished. Success is indicated in the success field.",
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfUpdateResponse"
+ }
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VNF delete",
+ "description": "VNF delete",
+ "operationId": "vnf_delete",
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VNF",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF delete parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfDeleteRequest"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "The VNF was successfully deleted."
+ }
+ }
+ }
+ },
+ "/so/v2/vfmodule/{vnfIdInAai}/{vfModuleId}": {
+ "post": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VF module create",
+ "description": "VF module create",
+ "operationId": "vf_module_create",
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF creation query parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VfModuleCreateRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "The VF module has been created"
+ }
+ }
+ },
+ "put": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VF module update",
+ "description": "VF module update",
+ "operationId": "vf_module_update",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF creation query parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfUpdateRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfUpdateResponse"
+ }
+ }
+ }
+ },
+ "delete": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VF module delete",
+ "description": "VF module delete",
+ "operationId": "vf_module_delete",
+ "consumes": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF delete parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2VnfDeleteRequest"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "The VNF was successfully deleted."
+ }
+ }
+ }
+ },
+ "/so/v2/vfmodule/{vnfIdInAai}/{vfModuleId}/rollback": {
+ "put": {
+ "tags": [
+ "SO VNFM Adaptor V2"
+ ],
+ "summary": "VF module update rollback",
+ "description": "VF module update rollback",
+ "operationId": "vf_module_update rollback",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of VNF in A&AI.",
+ "name": "vnfIdInAai",
+ "in": "path"
+ },
+ {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the VF module in A&AI",
+ "name": "vfModuleId",
+ "in": "path"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "VNF update rollback parameter",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/SoV2RollbackVnfUpdate"
+ }
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "Operation has been rolled back"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "SoMsoRequest": {
+ "type": "object",
+ "properties": {
+ "requestId": {
+ "required": true,
+ "description": "The identifier of the request in SO. Used to track requests.",
+ "type": "string"
+ },
+ "serviceInstanceId": {
+ "required": true,
+ "description": "The identifier of the service instance in A&AI.",
+ "type": "string"
+ }
+ }
+ },
+ "SoV2VnfQueryRequest": {
+ "type": "object",
+ "properties": {
+ "msoRequest": {
+ "required": true,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoVnfStatus": {
+ "description": "The status of the VNF",
+ "type": "string",
+ "enum": [
+ "ACTIVE",
+ "FAILED",
+ "NOTFOUND",
+ "UNKNOWN"
+ ]
+ },
+ "SoOutput": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "SoInput": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "SoV2VnfQueryResponse": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "required": true,
+ "description": "The status of the VNF",
+ "$ref": "#/definitions/SoVnfStatus"
+ }
+ }
+ },
+ "SoV2VnfCreateRequest": {
+ "type": "object",
+ "properties": {
+ "cloudOwner": {
+ "required": true,
+ "type": "string",
+ "description": "The owner of cloud in A&AI."
+ },
+ "regionName": {
+ "required": true,
+ "type": "string",
+ "description": "The regionName of cloud in A&AI."
+ },
+ "tenantId": {
+ "required": true,
+ "type": "string",
+ "description": "The identifier of the tenant."
+ },
+ "name": {
+ "required": true,
+ "type": "string",
+ "description": "The name of the VNF."
+ },
+ "inputs": {
+ "required": false,
+ "description": "The inputs of the VNF.",
+ "$ref": "#/definitions/SoInput"
+ },
+ "failIfExists": {
+ "required": false,
+ "description": "Should the VNF creation fail if the VNF already exists. (defaults to false)",
+ "type": "boolean"
+ },
+ "deleteUponFailure": {
+ "required": false,
+ "description": "Delete VNF in case of failure. (defaults to false)",
+ "type": "boolean"
+ },
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoMsoRollback": {
+ "type": "object",
+ "description": "Generic rollback parameters",
+ "properties": {
+ "deleteIfExists": {
+ "required": true,
+ "description": "Delete the VNF if exists",
+ "type": "boolean"
+ },
+ "vnfIdInAai": {
+ "required": true,
+ "description": "The identifier of the VNF in AAI",
+ "type": "string"
+ },
+ "msoRequest": {
+ "required": true,
+ "description": "The pointer to the original request that triggered the rollback",
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "OriginalVnfProperties": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "SoV2RollbackVnfUpdate": {
+ "type": "object",
+ "properties": {
+ "originalVnfProperties": {
+ "required": false,
+ "description": "The original VNF properties before the operation",
+ "$ref": "#/definitions/OriginalVnfProperties"
+ }
+ }
+ },
+ "SoV2VnfUpdateRequest": {
+ "type": "object",
+ "properties": {
+ "inputs": {
+ "required": false,
+ "description": "The inputs of the VNF.",
+ "$ref": "#/definitions/SoInput"
+ },
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoV2VnfUpdateResponse": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/SoV2RollbackVnfUpdate"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "successful": {
+ "required": true,
+ "description": "Is the update successful. The operation can be rolled back regardless of this attribute",
+ "type": "boolean"
+ }
+ }
+ }
+ ]
+ },
+ "SoV2VnfDeleteRequest": {
+ "type": "object",
+ "properties": {
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ },
+ "SoV2VfModuleCreateRequest": {
+ "type": "object",
+ "properties": {
+ "scalingAspectId": {
+ "required": true,
+ "description": "The identifier of the scaling aspect",
+ "type": "string"
+ },
+ "inputs": {
+ "required": false,
+ "description": "The inputs of the VNF.",
+ "$ref": "#/definitions/SoInput"
+ },
+ "failIfExists": {
+ "required": false,
+ "description": "Should the VNF creation fail if the VNF already exists. (defaults to false)",
+ "type": "boolean"
+ },
+ "deleteUponFailure": {
+ "required": false,
+ "description": "Delete VF module in case of failure. (defaults to false)",
+ "type": "boolean"
+ },
+ "msoRequest": {
+ "required": false,
+ "$ref": "#/definitions/SoMsoRequest"
+ }
+ }
+ }
+ }
+}
diff --git a/nokiav2/pom.xml b/nokiav2/pom.xml
index ad257e40..4407b882 100644
--- a/nokiav2/pom.xml
+++ b/nokiav2/pom.xml
@@ -23,12 +23,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
<artifactId>vfc-nfvo-driver-vnfm-svnfm-nokiav2</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>vfc-nfvo-driver-vnfm-svnfm-nokiav2</name>
<properties>
<jacoco.version>0.8.0</jacoco.version>
<spring.boot.version>2.0.2.RELEASE</spring.boot.version>
+ <driver.version>1.1.1-SNAPSHOT</driver.version>
</properties>
<!-- used to test dependency convergence locally
<build>
diff --git a/zte/vmanager/docker/Dockerfile b/zte/vmanager/docker/Dockerfile
index db1c6c9f..71d66bd5 100644
--- a/zte/vmanager/docker/Dockerfile
+++ b/zte/vmanager/docker/Dockerfile
@@ -23,7 +23,7 @@ ADD . /service
WORKDIR /service
# get binary zip from nexus - vfc-nfvo-driver-vnfm-svnfm-zte-vmanager
-RUN wget -q -O vfc-nfvo-driver-vnfm-svnfm-zte-vmanager.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.zte.vmanager&a=vfc-nfvo-driver-vnfm-svnfm-zte-vmanager&v=LATEST&e=zip' && \
+RUN wget -q -O vfc-nfvo-driver-vnfm-svnfm-zte-vmanager.zip 'https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.zte.vmanager&a=vfc-nfvo-driver-vnfm-svnfm-zte-vmanager&v=1.1.0-SNAPSHOT&e=zip' && \
unzip vfc-nfvo-driver-vnfm-svnfm-zte-vmanager.zip && \
rm -rf vfc-nfvo-driver-vnfm-svnfm-zte-vmanager.zip