summaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2019-04-25 11:31:45 +0000
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2019-05-02 05:51:46 +0000
commitac9387ceb0d2a4f1e1dd85be4e6d7818ab83363d (patch)
tree7c7d78f6837410e2b212f1075767b87964133aac /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java
parent5e1bc9f09bec49b57bde13a1c96158eb2b8290da (diff)
Fixed issues found in integration testing
Issue-ID: SO-1814 Change-Id: Ica6929e10cb40d535657eefc9786090af996ba32 Signed-off-by: MichaelMorris <michael.morris@est.tech> (cherry picked from commit df6508f90ffb0247b94a7357035e36af61b4f207)
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java')
-rwxr-xr-xadapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java100
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java4
-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/vnfm/VnfmHelper.java36
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java3
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java38
11 files changed, 128 insertions, 121 deletions
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 30ce0c2253..62d2f7e2a9 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,13 @@
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.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import static org.slf4j.LoggerFactory.getLogger;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
/**
* The spring boot application for the VNFM (Virtual Network Function Manager) Adapter.
@@ -36,6 +38,7 @@ import static org.slf4j.LoggerFactory.getLogger;
* SOL003 v2.5.1</a>
*/
@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
public class VnfmAdapterApplication {
private static final Logger logger = getLogger(VnfmAdapterApplication.class);
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
index f1074bcba8..fd92910e36 100644
--- 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
@@ -22,20 +22,21 @@
package org.onap.so.adapters.vnfmadapter.extclients;
+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.abortOperation;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
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;
@@ -48,25 +49,24 @@ import java.util.NoSuchElementException;
import java.util.Set;
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.abortOperation;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
+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;
@Component
public class SdcPackageProvider {
- private static final String GET_PACKAGE_URL = "%s/catalog/resources/%s/toscaModel";
+ private static final String GET_PACKAGE_URL = "%s/sdc/v1/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 final String TOSCA_VNFD_KEY = "Entry-Definitions";
private static Logger logger = getLogger(SdcPackageProvider.class);
@Value("${sdc.username}")
@@ -78,7 +78,7 @@ public class SdcPackageProvider {
@Value("${sdc.endpoint}")
private String baseUrl;
- public String getVnfdId(String csarId) {
+ public String getVnfdId(final String csarId) {
return getVnfNodeProperty(csarId, "descriptor_id");
}
@@ -96,7 +96,7 @@ public class SdcPackageProvider {
for (final JsonObject child : children(nodeTemplates)) {
final String type = childElement(child, "type").getAsString();
String propertyValue = null;
- if (type.equals("tosca.nodes.nfv.VNF")) {
+ if ("tosca.nodes.nfv.VNF".equals(type)) {
final JsonObject properties = child(child, "properties");
logger.debug("properties: " + properties.toString());
@@ -119,7 +119,7 @@ public class SdcPackageProvider {
final JsonObject nodeTypes = child(root, "node_types");
final JsonObject nodeType = child(nodeTypes, nodeTypeName);
- if (childElement(nodeType, "derived_from").getAsString().equals("tosca.nodes.nfv.VNF")) {
+ if ("tosca.nodes.nfv.VNF".equals(childElement(nodeType, "derived_from").getAsString())) {
final JsonObject properties = child(nodeType, "properties");
logger.debug("properties: " + properties.toString());
final JsonObject property = child(properties, propertyName);
@@ -130,34 +130,33 @@ public class SdcPackageProvider {
return null;
}
- private byte[] getPackage(String csarId) {
+ private byte[] getPackage(final String csarId) {
final String SERVICE_NAME = "vnfm-adapter";
try (CloseableHttpClient client = HttpClients.createDefault()) {
- HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
+ final 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);
+ final String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey);
+ final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ final 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);
- return bytes;
- } catch (Exception e) {
+ final CloseableHttpResponse response = client.execute(httpget);
+ final HttpEntity entity = response.getEntity();
+ final InputStream is = entity.getContent();
+ return toByteArray(is);
+ } catch (final Exception e) {
throw abortOperation("Unable to download " + csarId + " package from SDC", e);
}
}
- private String getVnfdLocation(InputStream stream) throws IOException {
- Iterator pathIterator = toscaMetaPaths.iterator();
+ private String getVnfdLocation(final InputStream stream) throws IOException {
+ final Iterator<String> pathIterator = toscaMetaPaths.iterator();
while (pathIterator.hasNext()) {
- String toscaMetadata = new String(getFileInZip(stream, pathIterator.next().toString()).toByteArray());
+ final String toscaMetadata = new String(getFileInZip(stream, pathIterator.next()).toByteArray());
if (!toscaMetadata.isEmpty()) {
- String toscaVnfdLine =
+ final String toscaVnfdLine =
filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next();
return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim();
}
@@ -165,20 +164,21 @@ public class SdcPackageProvider {
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);
+ private static ByteArrayOutputStream getFileInZip(final InputStream zip, final String path) throws IOException {
+ final ZipInputStream zipInputStream = new ZipInputStream(zip);
+ final ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path);
zipInputStream.close();
return fileContent;
}
- private static ByteArrayOutputStream getFileInZip(ZipInputStream zipInputStream, String path) throws IOException {
+ private static ByteArrayOutputStream getFileInZip(final ZipInputStream zipInputStream, final String path)
+ throws IOException {
ZipEntry zipEntry;
- Set<String> items = new HashSet<>();
+ final Set<String> items = new HashSet<>();
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
items.add(zipEntry.getName());
if (zipEntry.getName().matches(path)) {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ByteStreams.copy(zipInputStream, byteArrayOutputStream);
return byteArrayOutputStream;
}
@@ -187,7 +187,7 @@ public class SdcPackageProvider {
throw new NoSuchElementException("Unable to find the " + path + " in archive found: " + items);
}
- public String getFlavourId(String csarId) {
+ public String getFlavourId(final 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 50fd5bcf3a..867b6522f5 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,6 +20,9 @@
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;
@@ -40,9 +43,6 @@ 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.
@@ -257,7 +257,12 @@ public class AaiHelper {
relationship.setRelatedTo("tenant");
relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString());
+ relationship.getRelationshipData()
+ .add(createRelationshipData("cloud-region.cloud-owner", tenant.getCloudOwner()));
+ relationship.getRelationshipData()
+ .add(createRelationshipData("cloud-region.cloud-region-id", tenant.getRegionName()));
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/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
index f991ffafba..7021c02511 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
@@ -24,9 +24,9 @@ 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.GenericVnfs;
import org.onap.aai.domain.yang.Vserver;
import org.onap.vnfmadapter.v1.model.Tenant;
-import java.util.List;
/**
* Provides methods for invoking REST calls to AAI.
@@ -47,7 +47,7 @@ public interface AaiServiceProvider {
* @param selfLink the selfLink
* @return the matching generic vnfs
*/
- List<GenericVnf> invokeQueryGenericVnf(final String selfLink);
+ GenericVnfs invokeQueryGenericVnf(final String selfLink);
/**
* Invoke a GET request for the VNFMs.
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 fa07ab5720..50e579dd83 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
@@ -24,6 +24,7 @@ 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.GenericVnfs;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -32,7 +33,6 @@ 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 {
@@ -56,9 +56,9 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
}
@Override
- public List<GenericVnf> invokeQueryGenericVnf(final String selfLink) {
+ public GenericVnfs invokeQueryGenericVnf(final String selfLink) {
return aaiClientProvider.getAaiClient()
- .get(List.class,
+ .get(GenericVnfs.class,
AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS).queryParam("selflink", selfLink))
.orElseGet(() -> {
logger.debug("No vnf found in AAI with selflink: {}", selfLink);
@@ -104,7 +104,7 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
@Override
public void invokePutVserver(final String cloudOwner, final String cloudRegion, final String tenant,
final Vserver vserver) {
- aaiClientProvider.getAaiClient().update(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
+ aaiClientProvider.getAaiClient().create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
cloudRegion, tenant, vserver.getVserverId()), vserver);
}
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 31399f7720..249cf74cb2 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,10 +20,16 @@
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 com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
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;
@@ -40,7 +46,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilte
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.so.utils.CryptoUtils;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
import org.onap.vnfmadapter.v1.model.Tenant;
@@ -49,11 +55,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-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.
@@ -64,15 +65,19 @@ public class VnfmHelper {
private static final Logger logger = LoggerFactory.getLogger(VnfmHelper.class);
private static final String SEPARATOR = "_";
private final AaiServiceProvider aaiServiceProvider;
- private final WebSecurityConfig webSecurityConfig;
@Value("${vnfmadapter.endpoint}")
private String vnfmAdapterEndoint;
+ @Value("${vnfmadapter.auth:E39823AAB2739CC654C4E92B52C05BC34149342D0A46451B00CA508C8EDC62242CE4E9DA9445D3C01A3F13}")
+ private String vnfmAdapterAuth;
+
+ @Value("${mso.key}")
+ private String msoEncryptionKey;
+
@Autowired
- public VnfmHelper(final AaiServiceProvider aaiServiceProvider, final WebSecurityConfig webSecurityConfig) {
+ public VnfmHelper(final AaiServiceProvider aaiServiceProvider) {
this.aaiServiceProvider = aaiServiceProvider;
- this.webSecurityConfig = webSecurityConfig;
}
/**
@@ -171,8 +176,10 @@ public class VnfmHelper {
*
* @param the ID of the VNF notifications are required for
* @return the request
+ * @throws GeneralSecurityException
*/
- public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId) {
+ public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId)
+ throws GeneralSecurityException {
final LccnSubscriptionRequest lccnSubscriptionRequest = new LccnSubscriptionRequest();
lccnSubscriptionRequest.setAuthentication(getSubscriptionsAuthentication());
lccnSubscriptionRequest.setCallbackUri(vnfmAdapterEndoint + BASE_URL + OPERATION_NOTIFICATION_ENDPOINT);
@@ -186,12 +193,11 @@ public class VnfmHelper {
return lccnSubscriptionRequest;
}
- private SubscriptionsAuthentication getSubscriptionsAuthentication() {
+ private SubscriptionsAuthentication getSubscriptionsAuthentication() throws GeneralSecurityException {
final SubscriptionsAuthenticationParamsBasic basicAuthParams = new SubscriptionsAuthenticationParamsBasic();
- basicAuthParams.setUserName("vnfm");
- basicAuthParams.setPassword(webSecurityConfig.getUsercredentials().stream()
- .filter(userCredentials -> "vnfm".equals(userCredentials.getUsername())).findFirst().get()
- .getPassword());
+ final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":");
+ basicAuthParams.setUserName(decrypedAuth[0]);
+ basicAuthParams.setPassword(decrypedAuth[1]);
final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
authentication.addAuthTypeItem(AuthTypeEnum.BASIC);
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 951c6f187b..645f37e72f 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
@@ -84,10 +84,12 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
@Override
public InlineResponse2001 subscribeForNotifications(final String vnfmId,
final LccnSubscriptionRequest subscriptionRequest) {
+ logger.info("Subscribing for notifications {}", subscriptionRequest);
final String url = urlProvider.getSubscriptionsUrl(vnfmId);
ResponseEntity<InlineResponse2001> response = null;
try {
response = httpServiceProvider.postHttpRequest(subscriptionRequest, url, InlineResponse2001.class);
+ logger.info("Subscribing for notifications response {}", response);
} catch (final Exception exception) {
final String errorMessage =
"Subscription to VNFM " + vnfmId + " resulted in exception" + subscriptionRequest;
@@ -146,6 +148,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
@Override
public Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest) {
final String url = urlProvider.getCreationUrl(vnfmId);
+ logger.debug("Sending create request {} to : {}", createVnfRequest, url);
try {
return httpServiceProvider.post(createVnfRequest, url, InlineResponse201.class);
} catch (final Exception 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 d4aa65d159..f948f3cfac 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,6 +20,8 @@
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;
@@ -28,8 +30,6 @@ 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.
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 e6b787bacc..32bb9b93a4 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,6 +21,7 @@
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;
@@ -46,7 +47,6 @@ 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.
@@ -64,7 +64,7 @@ public class LifecycleManager {
@Autowired
LifecycleManager(final AaiServiceProvider aaiServiceProvider, final AaiHelper aaiHelper,
final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager,
- SdcPackageProvider packageProvider) {
+ final SdcPackageProvider packageProvider) {
this.aaiServiceProvider = aaiServiceProvider;
this.vnfmServiceProvider = vnfmServiceProvider;
this.aaiHelper = aaiHelper;
@@ -90,7 +90,11 @@ public class LifecycleManager {
aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId());
}
aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant());
- InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+ final InlineResponse201 vnfmResponse =
+ sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+
+ logger.info("Create response: {}", vnfmResponse);
+
genericVnf.setSelflink(vnfmResponse.getLinks().getSelf().getHref());
aaiServiceProvider.invokePutGenericVnf(genericVnf);
final String vnfIdInVnfm = vnfmResponse.getId();
@@ -135,18 +139,18 @@ public class LifecycleManager {
}
}
- private InlineResponse201 sendCreateRequestToVnfm(CreateVnfRequest aaiRequest, GenericVnf genericVnf,
- String vnfIdInAai, String vnfmId) {
+ private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf,
+ final String vnfIdInAai, final String vnfmId) {
logger.debug("Sending a create request to SVNFM " + aaiRequest);
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
+ final 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());
+ final String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId());
vnfmRequest.setVnfdId(vnfdId);
vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_"));
vnfmRequest.setVnfInstanceDescription(vnfIdInAai);
- Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
+ final Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
try {
return optionalResponse.get();
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 a339b9be70..d39a2cb761 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,6 +20,10 @@
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;
@@ -36,10 +40,6 @@ 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
@@ -93,8 +93,8 @@ public class NotificationHandler implements Runnable {
}
private void handleVnfInstantiateCompleted() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
setOamIpAddress(genericVnf, vnfInstance);
genericVnf.setOrchestrationStatus("Created");
@@ -141,16 +141,16 @@ public class NotificationHandler implements Runnable {
}
private void handleVnfTerminateFailed() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
vnfInstance.getVimConnectionInfo());
jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(), false);
}
private void handleVnfTerminateCompleted() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
vnfInstance.getVimConnectionInfo());
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 6b8802eed2..e241d0de7e 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,6 +20,11 @@
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;
@@ -36,15 +41,10 @@ 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.RequestMapping;
-import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-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;
+import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(value = BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@@ -52,9 +52,6 @@ public class Sol003GrantController {
private static final String SEPARATOR = "_";
private static final String VIM_TYPE = "OPENSTACK";
- private static final String CLOUD_OWNER = "myTestCloudOwner";
- private static final String REGION = "myTestRegion";
- private static final String TENANT_ID = "myTestTenantId";
private static final Logger logger = LoggerFactory.getLogger(Sol003GrantController.class);
public final AaiServiceProvider aaiServiceProvider;
public final AaiHelper aaiHelper;
@@ -71,7 +68,7 @@ public class Sol003GrantController {
@GetMapping(value = "/grants/{grantId}")
public ResponseEntity<InlineResponse201> grantsGrantIdGet(@PathVariable("grantId") final String grantId) {
logger.info("Get grant received from VNFM, grant id: " + grantId);
- return new ResponseEntity<InlineResponse201>(HttpStatus.NOT_IMPLEMENTED);
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@PostMapping(value = "/grants")
@@ -80,7 +77,7 @@ public class Sol003GrantController {
final InlineResponse201 grantResponse = createGrantResponse(grantRequest);
logger.info("Grant request returning to VNFM: " + grantResponse);
- return new ResponseEntity<InlineResponse201>(grantResponse, HttpStatus.CREATED);
+ return new ResponseEntity<>(grantResponse, HttpStatus.CREATED);
}
private InlineResponse201 createGrantResponse(final GrantRequest grantRequest) {
@@ -88,8 +85,9 @@ public class Sol003GrantController {
grantResponse.setId(UUID.randomUUID().toString());
grantResponse.setVnfInstanceId(grantRequest.getVnfInstanceId());
grantResponse.setVnfLcmOpOccId(grantRequest.getVnfLcmOpOccId());
- final Tenant tenant =
- aaiHelper.getAssignedTenant(aaiServiceProvider.invokeGetGenericVnf((grantRequest.getVnfInstanceId())));
+ final String vnfSelfLink = grantRequest.getLinks().getVnfInstance().getHref();
+ final Tenant tenant = aaiHelper
+ .getAssignedTenant(aaiServiceProvider.invokeQueryGenericVnf(vnfSelfLink).getGenericVnf().get(0));
String vimConnectionId = "";
final InlineResponse201VimConnections vimConnection = vnfmHelper.getVimConnections(tenant);
@@ -104,14 +102,6 @@ public class Sol003GrantController {
return grantResponse;
}
- private InlineResponse201VimConnections getVimConnectionsItem(final Tenant tenant) {
- final InlineResponse201VimConnections vimConnection = new InlineResponse201VimConnections();
- vimConnection.setId(createVimConnectionId(tenant.getCloudOwner(), tenant.getRegionName()));
- vimConnection.setVimId(vimConnection.getId());
- vimConnection.setVimType(VIM_TYPE);
- return vimConnection;
- }
-
private List<InlineResponse201AddResources> getResources(final List<GrantsAddResources> requestResources,
final String vimId) {
final List<InlineResponse201AddResources> resources = new ArrayList<>();
@@ -123,8 +113,4 @@ public class Sol003GrantController {
}
return resources;
}
-
- private String createVimConnectionId(String cloudOwner, String cloudRegionId) {
- return cloudOwner + SEPARATOR + cloudRegionId;
- }
}