aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2019-04-09 21:44:39 +0000
committerMichaelMorris <michael.morris@est.tech>2019-04-09 21:44:39 +0000
commit0a866176d0a9c221d699998131d498b78f0c7aed (patch)
tree15292bd03a65e7e8178727954606fc96b0105ee5 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org
parent8dae8791b36c45f6cf2124359c9055c7bee7cae2 (diff)
Add sending create request to VNFM
Change-Id: Id1c3f8b32533150a8983706bc28b3b02b9124bf5 Issue-ID: SO-1623 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java64
-rwxr-xr-xadapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java189
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java41
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java34
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java16
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java14
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java6
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java43
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java22
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java12
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java16
19 files changed, 397 insertions, 116 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java
new file mode 100644
index 0000000000..db34cbf3f2
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import org.slf4j.Logger;
+import java.util.ArrayList;
+import java.util.Collection;
+import static org.slf4j.LoggerFactory.getLogger;
+
+public class NvfmAdapterUtils {
+ private static Logger logger = getLogger(NvfmAdapterUtils.class);
+
+ public static JsonObject child(JsonObject parent, String name) {
+ return childElement(parent, name).getAsJsonObject();
+ }
+
+ public static JsonElement childElement(JsonObject parent, String name) {
+ JsonElement child = parent.get(name);
+ if (child == null) {
+ throw abortOperation("Missing child " + name);
+ }
+ return child;
+ }
+
+ public static Collection<JsonObject> children(JsonObject parent) {
+ ArrayList<JsonObject> childElements = new ArrayList<>();
+ for (String childKey : parent.keySet()) {
+ if (parent.get(childKey).isJsonObject()) {
+ childElements.add(parent.get(childKey).getAsJsonObject());
+ }
+ }
+ return childElements;
+ }
+
+ public static RuntimeException abortOperation(String msg, Exception e) {
+ logger.error(msg, e);
+ return new RuntimeException(msg, e);
+ }
+
+ public static RuntimeException abortOperation(String msg) {
+ logger.error(msg);
+ return new RuntimeException(msg);
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
index 2d80d558de..30ce0c2253 100755
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
@@ -20,11 +20,11 @@
package org.onap.so.adapters.vnfmadapter;
-import static org.slf4j.LoggerFactory.getLogger;
import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController;
import org.slf4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* The spring boot application for the VNFM (Virtual Network Function Manager) Adapter.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
new file mode 100644
index 0000000000..045b98007d
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
@@ -0,0 +1,189 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.extclients;
+
+import com.google.common.io.ByteStreams;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.Yaml;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import static com.google.common.base.Splitter.on;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.io.ByteStreams.toByteArray;
+import static java.lang.String.format;
+import static org.apache.http.HttpHeaders.ACCEPT;
+import static org.apache.http.HttpHeaders.AUTHORIZATION;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.*;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
+
+
+@Component
+public class SdcPackageProvider {
+ private static final String GET_PACKAGE_URL = "%s/catalog/resources/%s/toscaModel";
+ @Value("sdc.toscametapath:TOSCA-Metadata/TOSCA.meta")
+ private List<String> toscaMetaPaths;
+ private final String TOSCA_VNFD_KEY = "Entry-Definitions";
+ private static Logger logger = getLogger(SdcPackageProvider.class);
+
+ @Value("${sdc.username}")
+ private String sdcUsername;
+ @Value("${sdc.password}")
+ private String sdcPassword;
+ @Value("${sdc.key}")
+ private String sdcKey;
+ @Value("${sdc.endpoint}")
+ private String baseUrl;
+
+
+ public String getVnfdId(String csarId) {
+ return getVnfNodeProperty(csarId, "descriptor_id");
+ }
+
+ private String getVnfNodeProperty(final String csarId, final String propertyName) {
+ logger.debug("Getting " + propertyName + " from " + csarId);
+ final byte[] onapPackage = getPackage(csarId);
+
+ try {
+ final String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(onapPackage));
+ final String onapVnfdContent = getFileInZip(new ByteArrayInputStream(onapPackage), vnfdLocation).toString();
+ final JsonObject root = new Gson().toJsonTree(new Yaml().load(onapVnfdContent)).getAsJsonObject();
+
+ final JsonObject topologyTemplates = child(root, "topology_template");
+ final JsonObject nodeTemplates = child(topologyTemplates, "node_templates");
+ for (final JsonObject child : children(nodeTemplates)) {
+ final String type = childElement(child, "type").getAsString();
+ String propertyValue = null;
+ if (type.equals("tosca.nodes.nfv.VNF")) {
+ final JsonObject properties = child(child, "properties");
+ logger.debug("properties: " + properties.toString());
+
+ propertyValue = properties.get(propertyName).getAsJsonPrimitive().getAsString();
+ }
+ if (propertyValue == null) {
+ propertyValue = getValueFromNodeTypeDefinition(root, type, propertyName);
+ }
+ return propertyValue;
+ }
+
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("Unable to extract " + propertyName + " from ONAP package", e);
+ }
+ throw new IllegalArgumentException("Unable to extract " + propertyName + " from ONAP package");
+ }
+
+ private String getValueFromNodeTypeDefinition(final JsonObject root, final String nodeTypeName,
+ final String propertyName) {
+ final JsonObject nodeTypes = child(root, "node_types");
+ final JsonObject nodeType = child(nodeTypes, nodeTypeName);
+
+ if (childElement(nodeType, "derived_from").getAsString().equals("tosca.nodes.nfv.VNF")) {
+ final JsonObject properties = child(nodeType, "properties");
+ logger.debug("properties: " + properties.toString());
+ final JsonObject property = child(properties, propertyName);
+ logger.debug("property: " + property.toString());
+ logger.debug("property default: " + childElement(property, "default").toString());
+ return childElement(property, "default").getAsJsonPrimitive().getAsString();
+ }
+ return null;
+ }
+
+ private byte[] getPackage(String csarId) {
+ final String SERVICE_NAME = "vnfm-adapter";
+ try {
+ CloseableHttpClient client = HttpClients.createDefault();
+ HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
+ httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE);
+ httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME);
+ httpget.setHeader("X-FromAppId", SERVICE_NAME);
+ String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey);
+ byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ String authHeader = "Basic " + new String(encodedAuth);
+ httpget.setHeader(AUTHORIZATION, authHeader);
+ logger.debug("Fetching from SDC: " + httpget);
+ CloseableHttpResponse response = client.execute(httpget);
+ HttpEntity entity = response.getEntity();
+ InputStream is = entity.getContent();
+ byte[] bytes = toByteArray(is);
+ client.close();
+ return bytes;
+ } catch (Exception e) {
+ throw abortOperation("Unable to download " + csarId + " package from SDC", e);
+ }
+ }
+
+ private String getVnfdLocation(InputStream stream) throws IOException {
+ Iterator pathIterator = toscaMetaPaths.iterator();
+ while (pathIterator.hasNext()) {
+ String toscaMetadata = new String(getFileInZip(stream, pathIterator.next().toString()).toByteArray());
+ if (!toscaMetadata.isEmpty()) {
+ String toscaVnfdLine =
+ filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next();
+ return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim();
+ }
+ }
+ throw abortOperation("Unable to find valid Tosca Path");
+ }
+
+ private static ByteArrayOutputStream getFileInZip(InputStream zip, String path) throws IOException {
+ ZipInputStream zipInputStream = new ZipInputStream(zip);
+ ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path);
+ zipInputStream.close();
+ return fileContent;
+ }
+
+ private static ByteArrayOutputStream getFileInZip(ZipInputStream zipInputStream, String path) throws IOException {
+ ZipEntry zipEntry;
+ Set<String> items = new HashSet<>();
+ while ((zipEntry = zipInputStream.getNextEntry()) != null) {
+ items.add(zipEntry.getName());
+ if (zipEntry.getName().matches(path)) {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ ByteStreams.copy(zipInputStream, byteArrayOutputStream);
+ return byteArrayOutputStream;
+ }
+ }
+ logger.error("Unable to find the {} in archive found: {}", path, items);
+ throw new NoSuchElementException("Unable to find the " + path + " in archive found: " + items);
+ }
+
+
+ public String getFlavourId(String csarId) {
+ return getVnfNodeProperty(csarId, "flavour_id");
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
index b9ffd8bac5..88b8ba8ef0 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
@@ -20,18 +20,7 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import org.onap.aai.domain.yang.EsrSystemInfo;
-import org.onap.aai.domain.yang.EsrSystemInfoList;
-import org.onap.aai.domain.yang.EsrVnfm;
-import org.onap.aai.domain.yang.EsrVnfmList;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.Relationship;
-import org.onap.aai.domain.yang.RelationshipData;
-import org.onap.aai.domain.yang.RelationshipList;
-import org.onap.aai.domain.yang.Vserver;
+import org.onap.aai.domain.yang.*;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.TenantNotFoundException;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
@@ -43,6 +32,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
/**
* Provides helper methods for interactions with AAI.
@@ -72,7 +64,6 @@ public class AaiHelper {
final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList();
vnfmRelationshiplist.getRelationship().add(createRelationshipToVnfm(vnfmId));
- aaiServiceProvider.invokePutGenericVnf(vnf);
}
private Relationship createRelationshipToVnfm(final String vnfmId) {
@@ -237,4 +228,28 @@ public class AaiHelper {
public OamIpAddressSource getOamIpAddressSource(final String vnfId) {
return mapOfVnfIdToOamIpAddressHolder.get(vnfId);
}
+
+ /**
+ * Add a relationship to the given tenant to the given VNF.
+ *
+ * @param vnf the generic vnf
+ * @param tenant the Tenant
+ */
+
+ public void addRelationshipFromGenericVnfToTenant(final GenericVnf vnf, final Tenant tenant) {
+ if (vnf.getRelationshipList() == null) {
+ vnf.setRelationshipList(new RelationshipList());
+ }
+ final RelationshipList vnfmRelationshiplist = vnf.getRelationshipList();
+ vnfmRelationshiplist.getRelationship().add(createRelationshipToTenant(tenant));
+ }
+
+ private Relationship createRelationshipToTenant(final Tenant tenant) {
+ final Relationship relationship = new Relationship();
+ relationship.setRelatedTo("tenant");
+ relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
+ tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString());
+ relationship.getRelationshipData().add(createRelationshipData("tenant.tenant-id", tenant.getTenantId()));
+ return relationship;
+ }
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java
index ea12c5a265..cfaad3fd04 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java
@@ -20,12 +20,12 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
-import java.net.MalformedURLException;
-import java.net.URL;
import org.onap.so.client.aai.AAIProperties;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.spring.SpringContextHelper;
import org.springframework.context.ApplicationContext;
+import java.net.MalformedURLException;
+import java.net.URL;
public class AaiPropertiesImpl implements AAIProperties {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
index 2708742e6a..807f3bdb9d 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
@@ -20,13 +20,9 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
-import java.util.List;
-import org.onap.aai.domain.yang.EsrSystemInfoList;
-import org.onap.aai.domain.yang.EsrVnfm;
-import org.onap.aai.domain.yang.EsrVnfmList;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.Vserver;
+import org.onap.aai.domain.yang.*;
import org.onap.vnfmadapter.v1.model.Tenant;
+import java.util.List;
/**
* Provides methods for invoking REST calls to AAI.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
index 55a2cc39ec..4346114e34 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
@@ -20,12 +20,7 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
-import java.util.List;
-import org.onap.aai.domain.yang.EsrSystemInfoList;
-import org.onap.aai.domain.yang.EsrVnfm;
-import org.onap.aai.domain.yang.EsrVnfmList;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.Vserver;
+import org.onap.aai.domain.yang.*;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.vnfmadapter.v1.model.Tenant;
@@ -33,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.List;
@Service
public class AaiServiceProviderImpl implements AaiServiceProvider {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java
index 54b4055276..311c4de8bd 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java
@@ -20,8 +20,6 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
-import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType;
-
/**
* Represents the source of the value to use as the AAI OAM IP address of a VNF
*/
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
index b370dc35c8..70567d8631 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
@@ -20,27 +20,19 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.InterfaceInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.VimCredentials;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication.AuthTypeEnum;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter.NotificationTypesEnum;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo;
import org.onap.so.security.WebSecurityConfig;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
@@ -50,10 +42,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
/**
* Provides helper methods for interactions with VNFM.
@@ -81,10 +74,10 @@ public class VnfmHelper {
* @param tenant the tenant the request is to be fulfilled on
* @param createVnfRequest the request received by the VNFM adapter
*/
- public InstantiateVnfRequest createInstantiateRequest(final Tenant tenant,
- final CreateVnfRequest createVnfRequest) {
+ public InstantiateVnfRequest createInstantiateRequest(final Tenant tenant, final CreateVnfRequest createVnfRequest,
+ final String flavourId) {
final InstantiateVnfRequest instantiateVnfRequest = new InstantiateVnfRequest();
- instantiateVnfRequest.setFlavourId(getFlavourId());
+ instantiateVnfRequest.setFlavourId(flavourId);
instantiateVnfRequest.setVimConnectionInfo(getVimConnectionInfos(tenant));
instantiateVnfRequest
.setAdditionalParams(getAdditionalParametersAsJsonObject(createVnfRequest.getAdditionalParams()));
@@ -170,7 +163,6 @@ public class VnfmHelper {
* Create a {@link LccnSubscriptionRequest} to send in an notification subscription request to a VNFM.
*
* @param the ID of the VNF notifications are required for
- *
* @return the request
*/
public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId) {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java
index 472a8b8680..d061dd05c3 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java
@@ -21,12 +21,7 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
import com.google.common.base.Optional;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*;
/**
* Provides methods for invoking REST calls to a VNFM.
@@ -86,4 +81,13 @@ public interface VnfmServiceProvider {
*/
Optional<InlineResponse200> getOperation(final String vnfmId, final String operationId);
+ /**
+ * Invoke a create request to a VNFM
+ *
+ * @param vnfmId the id of the VNFM in AAI
+ * @param createVnfRequest the parameters for creating a VNF
+ * @return the newly created VNF
+ */
+ Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest);
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
index 88008c6a3f..164f12ea29 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
@@ -20,8 +20,6 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import java.util.Iterator;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
import org.onap.so.configuration.rest.HttpHeadersProvider;
import org.onap.so.rest.service.HttpRestServiceProvider;
@@ -34,6 +32,8 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
+import java.util.Iterator;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
/**
* Configures the HttpRestServiceProvider for REST call to a VNFM.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
index 104e2d11ac..b096f51cb0 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
@@ -21,12 +21,7 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
import com.google.common.base.Optional;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.slf4j.Logger;
@@ -142,4 +137,17 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
return httpServiceProvider.get(url, InlineResponse200.class);
}
+ @Override
+ public Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest) {
+ final String url = urlProvider.getCreationUrl(vnfmId);
+ try {
+ return httpServiceProvider.post(createVnfRequest, url, InlineResponse201.class);
+ } catch (final Exception exception) {
+ final String errorMessage =
+ "Create request to vnfm:" + vnfmId + " resulted in exception" + createVnfRequest;
+ logger.error(errorMessage, exception);
+ throw new VnfmRequestFailureException(errorMessage, exception);
+ }
+ }
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
index 2eaaa8113f..d4aa65d159 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
@@ -20,8 +20,6 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
-import static org.slf4j.LoggerFactory.getLogger;
-import java.net.URI;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
@@ -30,6 +28,8 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
+import java.net.URI;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides URLs for REST calls to a VNFM.
@@ -68,7 +68,15 @@ public class VnfmUrlProvider {
public String getSubscriptionsUrl(final String vnfmId) {
final String url =
UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/subscriptions").build().toString();
- logger.debug("getOperationUrl:" + url);
+ logger.debug("getSubscriptionUrl:" + url);
+
+ return url;
+ }
+
+ public String getCreationUrl(final String vnfmId) {
+ final String url =
+ UriComponentsBuilder.fromUri(getBaseUri(vnfmId)).pathSegment("/vnf_instances").build().toString();
+ logger.debug("getCreationUrl:" + url);
return url;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
index 7034b7f5ee..e61bf860b3 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
@@ -20,11 +20,8 @@
package org.onap.so.adapters.vnfmadapter.jobmanagement;
-import static org.slf4j.LoggerFactory.getLogger;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
-import java.util.Map;
-import java.util.UUID;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException;
@@ -35,6 +32,9 @@ import org.onap.vnfmadapter.v1.model.QueryJobResponse;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.Map;
+import java.util.UUID;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Manages jobs enabling the status of jobs to be queried. A job is associated with an operation on a VNFM.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
index 7085218c0b..e6b787bacc 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
@@ -21,9 +21,9 @@
package org.onap.so.adapters.vnfmadapter.lifecycle;
import com.google.common.base.Optional;
-import java.util.Map;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource;
@@ -38,6 +38,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfReques
import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfNotFoundException;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
@@ -45,6 +46,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.Map;
/**
* Manages lifecycle operations towards the VNFMs.
@@ -57,15 +59,18 @@ public class LifecycleManager {
private final AaiHelper aaiHelper;
private final VnfmHelper vnfmHelper;
private final JobManager jobManager;
+ private final SdcPackageProvider packageProvider;
@Autowired
LifecycleManager(final AaiServiceProvider aaiServiceProvider, final AaiHelper aaiHelper,
- final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager) {
+ final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager,
+ SdcPackageProvider packageProvider) {
this.aaiServiceProvider = aaiServiceProvider;
this.vnfmServiceProvider = vnfmServiceProvider;
this.aaiHelper = aaiHelper;
this.vnfmHelper = vnfmHelper;
this.jobManager = jobManager;
+ this.packageProvider = packageProvider;
}
/**
@@ -84,8 +89,11 @@ public class LifecycleManager {
vnfm = aaiHelper.selectVnfm(genericVnf);
aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId());
}
-
- final String vnfIdInVnfm = sendCreateRequestToVnfm(genericVnf);
+ aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant());
+ InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+ genericVnf.setSelflink(vnfmResponse.getLinks().getSelf().getHref());
+ aaiServiceProvider.invokePutGenericVnf(genericVnf);
+ final String vnfIdInVnfm = vnfmResponse.getId();
final OamIpAddressSource oamIpAddressSource = extractOamIpAddressSource(request);
aaiHelper.setOamIpAddressSource(vnfIdInVnfm, oamIpAddressSource);
@@ -127,10 +135,26 @@ public class LifecycleManager {
}
}
- private String sendCreateRequestToVnfm(final GenericVnf genericVnf) {
- // TODO call create request
- genericVnf.setSelflink("http://dummy.value/until/create/implememted/vnfId");
- return "vnfId";
+ private InlineResponse201 sendCreateRequestToVnfm(CreateVnfRequest aaiRequest, GenericVnf genericVnf,
+ String vnfIdInAai, String vnfmId) {
+ logger.debug("Sending a create request to SVNFM " + aaiRequest);
+ org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
+ new org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest();
+
+ String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId());
+ vnfmRequest.setVnfdId(vnfdId);
+ vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_"));
+ vnfmRequest.setVnfInstanceDescription(vnfIdInAai);
+
+ Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
+
+ try {
+ return optionalResponse.get();
+ } catch (final Exception exception) {
+ final String errorMessage = "Unable to return response from VNFM";
+ logger.error(errorMessage, exception);
+ throw new VnfmRequestFailureException(errorMessage, exception);
+ }
}
private void createNotificationSubscription(final String vnfmId, final String vnfId) {
@@ -148,7 +172,8 @@ public class LifecycleManager {
final CreateVnfRequest createVnfRequest, final String vnfIdInAai, final String vnfIdInVnfm) {
final InstantiateVnfRequest instantiateVnfRequest =
- vnfmHelper.createInstantiateRequest(createVnfRequest.getTenant(), createVnfRequest);
+ vnfmHelper.createInstantiateRequest(createVnfRequest.getTenant(), createVnfRequest,
+ packageProvider.getFlavourId(genericVnf.getModelVersionId()));
final String jobId = vnfmServiceProvider.instantiateVnf(genericVnf.getSelflink(), instantiateVnfRequest);
logger.info("Instantiate VNF request successfully sent to " + genericVnf.getSelflink());
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index 506eb8db0e..a339b9be70 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -20,10 +20,6 @@
package org.onap.so.adapters.vnfmadapter.notificationhandling;
-import static org.slf4j.LoggerFactory.getLogger;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.domain.yang.GenericVnf;
@@ -40,6 +36,10 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager;
import org.slf4j.Logger;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Performs updates to AAI based on a received notification. The updates are executed in a separate thread so as the
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
index 82e72a7630..a16c3fb5cc 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
@@ -20,19 +20,10 @@
package org.onap.so.adapters.vnfmadapter.rest;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import javax.ws.rs.core.MediaType;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201AddResources;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.*;
import org.onap.vnfmadapter.v1.model.Tenant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,11 +31,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
@Controller
@RequestMapping(value = BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java
index 0441342b79..9cb09e6261 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java
@@ -20,12 +20,6 @@
package org.onap.so.adapters.vnfmadapter.rest;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
-import static org.slf4j.LoggerFactory.getLogger;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.ws.rs.core.MediaType;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
@@ -45,6 +39,12 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import javax.ws.rs.core.MediaType;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Controller for handling notifications from the VNFM (Virtual Network Function Manager).
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java
index 875d3350bc..1cf00da499 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java
@@ -20,9 +20,7 @@
package org.onap.so.adapters.vnfmadapter.rest;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import javax.validation.Valid;
-import javax.ws.rs.core.MediaType;
+import io.swagger.annotations.ApiParam;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager;
import org.onap.so.adapters.vnfmadapter.lifecycle.LifecycleManager;
@@ -37,14 +35,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import io.swagger.annotations.ApiParam;
+import org.springframework.web.bind.annotation.*;
+import javax.validation.Valid;
+import javax.ws.rs.core.MediaType;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
/**
* Controller for handling requests to the VNFM (Virtual Network Function Manager) adapter REST API.