diff options
author | MichaelMorris <michael.morris@est.tech> | 2019-04-09 21:44:39 +0000 |
---|---|---|
committer | MichaelMorris <michael.morris@est.tech> | 2019-04-09 21:44:39 +0000 |
commit | 0a866176d0a9c221d699998131d498b78f0c7aed (patch) | |
tree | 15292bd03a65e7e8178727954606fc96b0105ee5 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src | |
parent | 8dae8791b36c45f6cf2124359c9055c7bee7cae2 (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')
25 files changed, 499 insertions, 205 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. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml index bbe13152fc..4fb110349d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml @@ -14,16 +14,22 @@ server: port: 9092 tomcat: - max-threads: 50 - + max-threads: 50 + mso: key: 07a7159d3bf51a0e53be7a8f89699be7 - + aai: auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 version: v15 endpoint: https://aai.onap:8443 +sdc: + username: sdcUser + password: sdcPassword + key: adadadadad + endpoint: http://sdc.onap/1234A + #Actuator management: endpoints: diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java index c25d8257d8..07c471ec87 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java @@ -20,8 +20,6 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import java.net.URI; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; @@ -33,6 +31,8 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import java.net.URI; +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java index 21c6eff6b0..7e87e669e2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java @@ -20,24 +20,14 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import java.util.Optional; +import com.google.gson.Gson; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.hamcrest.MockitoHamcrest; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.aai.domain.yang.EsrSystemInfoList; -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.*; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum; @@ -59,7 +49,12 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; -import com.google.gson.Gson; +import java.util.Optional; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java index aa089e1348..363780dcc5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java @@ -20,25 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import com.google.gson.Gson; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import javax.inject.Inject; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; @@ -54,13 +36,8 @@ import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationComputeResource; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfIdentifierCreationNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; @@ -82,6 +59,17 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +import javax.inject.Inject; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java index c69b483592..39572c73cd 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java @@ -20,21 +20,7 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; -import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import com.google.gson.Gson; -import java.net.URI; -import java.util.Optional; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; @@ -42,28 +28,16 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.hamcrest.MockitoHamcrest; -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.*; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -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.SdcPackageProvider; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.CreateVnfResponse; -import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; -import org.onap.vnfmadapter.v1.model.OperationEnum; -import org.onap.vnfmadapter.v1.model.OperationStateEnum; -import org.onap.vnfmadapter.v1.model.QueryJobResponse; import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.vnfmadapter.v1.model.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -82,6 +56,16 @@ import org.springframework.web.client.RestTemplate; import org.threeten.bp.LocalDateTime; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.ZoneOffset; +import java.net.URI; +import java.util.Optional; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.*; @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @@ -107,6 +91,9 @@ public class VnfmAdapterControllerTest { @MockBean AAIResourcesClient aaiResourcesClient; + @MockBean + SdcPackageProvider sdcPackageProvider; + @Autowired VnfmAdapterController controller; Gson gson = new Gson(); @@ -128,11 +115,16 @@ public class VnfmAdapterControllerTest { final String expectedsubscriptionRequest = "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke\"}}}"; final InlineResponse2001 subscriptionResponse = new InlineResponse2001(); + + final InlineResponse201 createResponse = createCreateResponse(); + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances")) + .andRespond(withSuccess(gson.toJson(createResponse), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo("http://vnfm2:8080/subscriptions")) .andExpect(content().json(expectedsubscriptionRequest)) .andRespond(withSuccess(gson.toJson(subscriptionResponse), MediaType.APPLICATION_JSON)); - mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate")) + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances/vnfId/instantiate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); @@ -163,12 +155,20 @@ public class VnfmAdapterControllerTest { assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId", uriArgument.getValue().build().toString()); assertEquals("myTestVnfId", genericVnfArgument.getValue().getVnfId()); - assertEquals(1, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); - final Relationship createdRelationship = + assertEquals(2, genericVnfArgument.getValue().getRelationshipList().getRelationship().size()); + final Relationship vnfmRelationship = genericVnfArgument.getValue().getRelationshipList().getRelationship().get(0); - assertEquals("esr-vnfm", createdRelationship.getRelatedTo()); - assertEquals("tosca.relationships.DependsOn", createdRelationship.getRelationshipLabel()); - assertEquals("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/vnfm2", createdRelationship.getRelatedLink()); + assertEquals("esr-vnfm", vnfmRelationship.getRelatedTo()); + assertEquals("tosca.relationships.DependsOn", vnfmRelationship.getRelationshipLabel()); + assertEquals("/aai/v15/external-system/esr-vnfm-list/esr-vnfm/vnfm2", vnfmRelationship.getRelatedLink()); + + final Relationship tenantRelationship = + genericVnfArgument.getValue().getRelationshipList().getRelationship().get(1); + assertEquals("tenant", tenantRelationship.getRelatedTo()); + assertEquals( + "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/myTestCloudOwner/myTestRegion/tenants/tenant/myTestTenantId", + tenantRelationship.getRelatedLink()); + // check the job status @@ -223,9 +223,13 @@ public class VnfmAdapterControllerTest { setUpVnfmsInMockAai(); setUpVimInMockAai(); + final InlineResponse201 createResponse = createCreateResponse(); + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances")) + .andRespond(withSuccess(gson.toJson(createResponse), MediaType.APPLICATION_JSON)); + mockRestServer.expect(requestTo("http://vnfm2:8080/subscriptions")).andRespond(withBadRequest()); - mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate")) + mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_instances/vnfId/instantiate")) .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON) .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); @@ -469,6 +473,19 @@ public class VnfmAdapterControllerTest { + CLOUD_OWNER + "/" + REGION + "/esr-system-info-list"))); } + private InlineResponse201 createCreateResponse() { + final InlineResponse201 createResponse = new InlineResponse201(); + createResponse.setVnfdId("myTestVnfd"); + final InlineResponse201Links links = new InlineResponse201Links(); + final InlineResponse201LinksSelf self = new InlineResponse201LinksSelf(); + self.setHref("http://vnfm2:8080/vnf_instances/vnfId"); + links.setSelf(self); + createResponse.setLinks(links); + createResponse.setId("vnfId"); + return createResponse; + } + + private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> { final String uriAsString; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml index e69e90173d..3afc542a1b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application-test.yaml @@ -14,20 +14,27 @@ spring: security: usercredentials: - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPEL-Client - - username: vnfm - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - + - username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client + - username: vnfm + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + mso: key: 07a7159d3bf51a0e53be7a8f89699be7 - + aai: auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 endpoint: https://aai.onap:8443 version: v15 - + +sdc: + username: sdcUser + password: sdcPassword + key: adadadadad + endpoint: http://sdc.onap/1234A + + vnfmadapter: - endpoint: https://so-vnfm-adapter.onap:30406
\ No newline at end of file + endpoint: https://so-vnfm-adapter.onap:30406 |