summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nokiav2/docs/.gitignore2
-rw-r--r--nokiav2/docs/sampleVnfs/simple/cbam.package.zipbin0 -> 6902 bytes
-rw-r--r--nokiav2/docs/sampleVnfs/simple/simple.v1.csar (renamed from nokiav2/docs/sampleVnfs/simple/simple.csar)bin11484 -> 11484 bytes
-rw-r--r--nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zipbin0 -> 6902 bytes
-rw-r--r--nokiav2/docs/sampleVnfs/simple_cmcc/simple.v1.csar (renamed from nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar)bin11484 -> 11484 bytes
-rw-r--r--nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csarbin0 -> 7773 bytes
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java8
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java3
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java74
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java (renamed from nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java)15
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java276
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java60
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java25
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java19
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java10
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java2
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java35
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java6
-rw-r--r--nokiav2/driver/src/main/resources/self.swagger.json8
-rw-r--r--nokiav2/driver/src/main/resources/upload.html7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java3
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java76
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java10
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java6
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java18
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java3
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java39
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java5
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java7
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java1
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java1
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml8
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml21
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml25
-rw-r--r--nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml133
50 files changed, 782 insertions, 177 deletions
diff --git a/nokiav2/docs/.gitignore b/nokiav2/docs/.gitignore
index bd19fff5..b74d7233 100644
--- a/nokiav2/docs/.gitignore
+++ b/nokiav2/docs/.gitignore
@@ -2,3 +2,5 @@ _build
.DS_Store
internal.rst
ims
+tmp
+cscf
diff --git a/nokiav2/docs/sampleVnfs/simple/cbam.package.zip b/nokiav2/docs/sampleVnfs/simple/cbam.package.zip
new file mode 100644
index 00000000..1e0eaaf8
--- /dev/null
+++ b/nokiav2/docs/sampleVnfs/simple/cbam.package.zip
Binary files differ
diff --git a/nokiav2/docs/sampleVnfs/simple/simple.csar b/nokiav2/docs/sampleVnfs/simple/simple.v1.csar
index bdea8ad8..bdea8ad8 100644
--- a/nokiav2/docs/sampleVnfs/simple/simple.csar
+++ b/nokiav2/docs/sampleVnfs/simple/simple.v1.csar
Binary files differ
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zip b/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zip
new file mode 100644
index 00000000..46a85d7a
--- /dev/null
+++ b/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.package.zip
Binary files differ
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v1.csar
index bdea8ad8..bdea8ad8 100644
--- a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar
+++ b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v1.csar
Binary files differ
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar
new file mode 100644
index 00000000..dbb6cdad
--- /dev/null
+++ b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.v2.csar
Binary files differ
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
index f1c2a6f0..91240103 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
@@ -82,6 +82,10 @@ public class NokiaSvnfmApplication {
this.selfRegistrationManagerForSo = selfRegistrationManagerForSo;
}
+ private static boolean isDirect(ConfigurableApplicationContext applicationContext) {
+ return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct");
+ }
+
@Override
public void onApplicationEvent(ApplicationReadyEvent contextRefreshedEvent) {
Callable<Boolean> singleRegistration = () -> {
@@ -116,10 +120,6 @@ public class NokiaSvnfmApplication {
});
}
- private static boolean isDirect(ConfigurableApplicationContext applicationContext) {
- return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct");
- }
-
}
/**
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
index 164d3a23..48c008ac 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
@@ -100,8 +100,7 @@ public class GenericVnfManager extends AbstractManager {
}
if (nsId.isPresent()) {
addSingletonRelation(vnf.getRelationshipList(), linkToNs(nsId.get()));
- }
- else{
+ } else {
logger.warn("Not linking VNF with {} identifier to any NS", vnfId);
}
aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst();
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java
new file mode 100644
index 00000000..f7f247a0
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.regex.Pattern;
+import org.slf4j.Logger;
+import org.yaml.snakeyaml.Yaml;
+
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Transforms a CBAM package into an ONAP package
+ */
+public class OnapAbstractVnfdBuilder {
+ public static final String DESCRIPTION = "description";
+ public static final String PROPERTIES = "properties";
+ public static final String REQUIREMENTS = "requirements";
+ private static Logger logger = getLogger(OnapAbstractVnfdBuilder.class);
+
+ @VisibleForTesting
+ static String indent(String content, int prefixSize) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < prefixSize; i++) {
+ sb.append(" ");
+ }
+ Pattern pattern = Pattern.compile("^(.*)$", Pattern.MULTILINE);
+ return pattern.matcher(content).replaceAll(sb.toString() + "$1");
+ }
+
+ protected static String getRequirement(JsonArray requirements, String key) {
+ for (int i = 0; i < requirements.size(); i++) {
+ JsonElement requirement = requirements.get(i);
+ Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
+ String s = next.getKey();
+ if (key.equals(s)) {
+ return next.getValue().getAsString();
+ }
+ }
+ return null;
+ }
+
+ private JsonElement get(String name, Set<Map.Entry<String, JsonElement>> nodes) {
+ for (Map.Entry<String, JsonElement> node : nodes) {
+ if (name.equals(node.getKey())) {
+ return node.getValue();
+ }
+ }
+ throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node");
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java
index 2a058777..6542a032 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java
@@ -33,7 +33,7 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getV
* Transforms a CBAM package into an ONAP package
*/
-public class OnapVnfPackageBuilder {
+public class OnapR1VnfPackageBuilder {
/**
* Entry point for the command line package transformer
@@ -41,20 +41,23 @@ public class OnapVnfPackageBuilder {
* @param args not used (required due to signature)
*/
public static void main(String[] args) throws Exception {
- byte[] covert = new OnapVnfPackageBuilder().covert(systemFunctions().in());
+ byte[] covert = new OnapR1VnfPackageBuilder().covert(systemFunctions().in(), SupportedOnapPackageVersions.V1);
systemFunctions().out().write(covert);
}
/**
- * @param zip the original CBAM package
+ * @param zip the original CBAM package
+ * @param version
* @return the converted ONAP package
*/
- public byte[] covert(InputStream zip) throws IOException {
+ public byte[] covert(InputStream zip, SupportedOnapPackageVersions version) throws IOException {
byte[] cbamVnfPackage = ByteStreams.toByteArray(zip);
String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(cbamVnfPackage));
ByteArrayOutputStream vnfdContent = getFileInZip(new ByteArrayInputStream(cbamVnfPackage), vnfdLocation);
byte[] cbamVnfdContent = vnfdContent.toByteArray();
- String onapVnfd = new OnapVnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8));
+ String onapVnfd = SupportedOnapPackageVersions.V2 == version ?
+ new OnapR2VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)) :
+ new OnapVnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8));
byte[] modifiedCbamPackage = new CbamVnfPackageBuilder().toModifiedCbamVnfPackage(cbamVnfPackage, vnfdLocation, new CbamVnfdBuilder().build(new String(cbamVnfdContent)));
return buildNewOnapPackage(modifiedCbamPackage, onapVnfd);
}
@@ -78,6 +81,4 @@ public class OnapVnfPackageBuilder {
out.close();
return result.toByteArray();
}
-
-
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java
new file mode 100644
index 00000000..099f641c
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.slf4j.Logger;
+import org.yaml.snakeyaml.Yaml;
+
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder.getRequirement;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder.indent;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Transforms a CBAM package into an ONAP package
+ */
+public class OnapR2VnfdBuilder {
+ public static final String DESCRIPTION = "description";
+ public static final String PROPERTIES = "properties";
+ public static final String REQUIREMENTS = "requirements";
+ private static Logger logger = getLogger(OnapR2VnfdBuilder.class);
+
+ private static String trimUnit(String data) {
+ //FIXME the unit should not be trimmed VF-C bug
+ return data;
+ //data.trim().replaceAll("[^0-9]", "");
+ }
+
+ /**
+ * @param cbamVnfd the CBAM VNFD
+ * @return the converted ONAP VNFD
+ */
+ public String toOnapVnfd(String cbamVnfd) {
+ JsonObject root = new Gson().toJsonTree(new Yaml().load(cbamVnfd)).getAsJsonObject();
+ JsonObject topologyTemplate = child(root, "topology_template");
+ JsonObject substitution_mappings = child(topologyTemplate, "substitution_mappings");
+ Map<String, JsonElement> virtualLinks = new HashMap<>();
+ if (topologyTemplate.has("node_templates")) {
+ Set<Map.Entry<String, JsonElement>> nodeTemplates = child(topologyTemplate, "node_templates").entrySet();
+
+ StringBuilder body = new StringBuilder();
+ for (Map.Entry<String, JsonElement> node : nodeTemplates) {
+ String type = childElement(node.getValue().getAsJsonObject(), "type").getAsString();
+ if ("tosca.nodes.nfv.VDU".equals(type)) {
+ body.append(buildVdu(node.getKey(), substitution_mappings, node.getValue().getAsJsonObject(), nodeTemplates));
+ } else if ("tosca.nodes.nfv.VirtualStorage".equals(type)) {
+ body.append(buildVolume(node.getKey(), node.getValue().getAsJsonObject()));
+ } else if ("tosca.nodes.nfv.VL".equals(type)) {
+ virtualLinks.put(node.getKey(), node.getValue());
+ body.append(buildVl(node.getValue().getAsJsonObject().get(PROPERTIES).getAsJsonObject(), node.getKey()));
+ } else if ("tosca.nodes.nfv.ICP".equals(type)) {
+ body.append(buildIcp(node.getKey(), node.getValue().getAsJsonObject()));
+ } else if ("tosca.nodes.nfv.ECP".equals(type)) {
+ body.append(buildEcp(node.getKey(), node.getValue(), nodeTemplates));
+ } else {
+ logger.warn("The {} type is not converted", type);
+ }
+ }
+ return buildHeader(topologyTemplate, virtualLinks) + body.toString();
+ }
+ return buildHeader(topologyTemplate, virtualLinks);
+ }
+
+ private String buildHeader(JsonObject toplogyTemplate, Map<String, JsonElement> virtualLinks) {
+ JsonObject substitution_mappings = child(toplogyTemplate, "substitution_mappings");
+ String vnfContent = buildVnf(substitution_mappings, virtualLinks);
+ return "tosca_definitions_version: tosca_simple_profile_yaml_1_1\n" +
+ "\n" +
+ "topology_template:\n" +
+ " inputs:\n" +
+ " etsi_config:\n" +
+ " type: string\n" +
+ " description: The ETSI configuration\n" +
+ " node_templates:\n" + vnfContent;
+ }
+
+ private JsonElement get(String name, Set<Map.Entry<String, JsonElement>> nodes) {
+ for (Map.Entry<String, JsonElement> node : nodes) {
+ if (name.equals(node.getKey())) {
+ return node.getValue();
+ }
+ }
+ throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node");
+ }
+
+ private String buildVdu(String name, JsonObject vnf, JsonObject vdu, Set<Map.Entry<String, JsonElement>> nodes) {
+ String memorySize = "";
+ String cpuCount = "";
+ StringBuilder body = new StringBuilder();
+ JsonArray vduRequirements = childElement(vdu.getAsJsonObject(), REQUIREMENTS).getAsJsonArray();
+ for (int i = 0; i < vduRequirements.size(); i++) {
+ JsonObject requirement = vduRequirements.get(i).getAsJsonObject();
+ Map.Entry<String, JsonElement> next = requirement.entrySet().iterator().next();
+ String s = next.getKey();
+ if ("virtual_compute".equals(s)) {
+ JsonObject virtualCompute = get(next.getValue().getAsString(), nodes).getAsJsonObject();
+ cpuCount = childElement(child(child(virtualCompute, PROPERTIES), "virtual_cpu"), "num_virtual_cpu").getAsString();
+ memorySize = trimUnit(childElement(child(child(virtualCompute, PROPERTIES), "virtual_memory"), "virtual_mem_size").getAsString());
+ } else if ("virtual_storage".equals(s)) {
+ String item = indent(
+ "- virtual_storage:\n" +
+ " capability: tosca.capabilities.nfv.VirtualStorage\n" +
+ " node: " + next.getValue().getAsString() + "\n", 4);
+ body.append(item);
+ }
+ next.getValue();
+ }
+ JsonObject flavourProperties = child(child(child(vnf, "capabilities"), "deployment_flavour"), "properties");
+ JsonObject vduSizes = child(child(flavourProperties, "vdu_profile"), name);
+ String header = indent(name + ":\n" +
+ " type: tosca.nodes.nfv.Vdu.Compute\n" +
+ " properties:\n" +
+ " name: " + name + "\n" +
+ " description: " + childElement(child(vdu, PROPERTIES), "description").getAsString() + "\n" +
+ " configurable_properties:\n" +
+ " vdu_profile:\n" +
+ " min_number_of_instances: " + childElement(vduSizes, "min_number_of_instances").getAsString() + "\n" +
+ " max_number_of_instances: " + childElement(vduSizes, "max_number_of_instances").getAsString() + "\n" +
+ " capabilities:\n" +
+ " virtual_compute:\n" +
+ indent(
+ "properties:\n" +
+ " virtual_memory:\n" +
+ " virtual_mem_size: " + trimUnit(memorySize) + "\n" +
+ " virtual_cpu:\n" +
+ " num_virtual_cpu: " + cpuCount + "\n", 3) +
+ " " + REQUIREMENTS + ":\n", 2);
+ return header + body.toString();
+ }
+
+ private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
+ if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
+ String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
+ if (icpName != null) {
+ return buildEcpInternal(name, icpName, nodes);
+ } else {
+ logger.warn("The {} ecp does not have an internal connection point", name);
+ }
+ } else {
+ logger.warn("The {} ecp does not have an requirements section", name);
+ }
+ return "";
+ }
+
+ private String buildVnf(JsonObject vnf, Map<String, JsonElement> virtualLinks) {
+ JsonObject vnfProperties = child(vnf, PROPERTIES);
+ JsonObject flavourProperties = child(child(child(vnf, "capabilities"), "deployment_flavour"), "properties");
+ StringBuilder vlContent = new StringBuilder();
+ for (Map.Entry<String, JsonElement> virtualLink : virtualLinks.entrySet()) {
+ vlContent.append(indent("- virtual_link:\n" +
+ " capability: tosca.capabilities.nfv.VirtualLinkable\n" +
+ " node: " + virtualLink.getKey() + "\n", 4));
+ }
+ return indent("VNF:\n" +
+ " type: tosca.nodes.nfv.VNF\n" +
+ " " + PROPERTIES + ":\n" +
+ " descriptor_id: " + childElement(vnfProperties, "descriptor_id").getAsString() + "\n" +
+ " descriptor_version: " + childElement(vnfProperties, "descriptor_version").getAsString() + "\n" +
+ " provider: " + childElement(vnfProperties, "provider").getAsString() + "\n" +
+ " product_name: " + childElement(vnfProperties, "product_name").getAsString() + "\n" +
+ " software_version: " + childElement(vnfProperties, "software_version").getAsString() + "\n" +
+ " product_info_name: " + childElement(vnfProperties, "product_info_name").getAsString() + "\n" +
+ (vnfProperties.has("product_info_description") ?
+ " product_info_description: " + childElement(vnfProperties, "product_info_description").getAsString() + "\n" : "") +
+ " vnfm_info: [ " + SelfRegistrationManager.SERVICE_NAME + " ]\n" +
+ " flavour_id: " + childElement(flavourProperties, "flavour_id").getAsString() + "\n" +
+ " flavour_description: " + childElement(flavourProperties, "description").getAsString() + "\n", 2) +
+ " " + REQUIREMENTS + ":\n" +
+ vlContent.toString();
+ }
+
+ private String buildEcpInternal(String ecpName, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
+ JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
+ if (icpNode.has(REQUIREMENTS)) {
+ String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding");
+ //internal connection point is bound to VDU
+ if (vdu != null) {
+ return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES));
+ } else {
+ logger.warn("The {} internal connection point of the {} ecp does not have a VDU", icpName, ecpName);
+ }
+ } else {
+ logger.warn("The {} internal connection point of the {} ecp does not have a requirements section", icpName, ecpName);
+ }
+ return "";
+ }
+
+ private String buildIcp(String name, JsonObject icp) {
+ if (icp.has(REQUIREMENTS)) {
+ JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray();
+ String vdu = getRequirement(requirements, "virtual_binding");
+ String vl = getRequirement(requirements, "virtual_link");
+ if (vdu == null) {
+ logger.warn("The {} internal connection point does not have a VDU", name);
+ } else if (vl == null) {
+ logger.warn("The {} internal connection point does not have a VL", name);
+ } else {
+ JsonObject properties = child(icp, PROPERTIES);
+ return indent(name + ":\n" +
+ " type: tosca.nodes.nfv.VduCp\n" +
+ " " + PROPERTIES + ":\n" +
+ " layer_protocol: [ " + childElement(properties, "layer_protocol").getAsString() + " ]\n" +
+ (properties.has(DESCRIPTION) ?
+ " description: " + childElement(properties, DESCRIPTION).getAsString() + "\n" : "") +
+ " protocol_data: []\n" +
+ " trunk_mode: false\n" +
+ " requirements:\n" +
+ " - virtual_binding: " + vdu + "\n" +
+ " - virtual_link: " + vl + "\n", 2);
+ }
+ } else {
+ logger.warn("The {} internal connection point does not have a requirements section", name);
+ }
+ return "";
+ }
+
+ private String buildVduCpd(String name, String vdu, JsonObject properties) {
+ return indent(name + ":\n" +
+ " type: tosca.nodes.nfv.VduCp\n" +
+ " " + PROPERTIES + ":\n" +
+ " layer_protocol: [ " + childElement(properties, "layer_protocol").getAsString() + " ]\n" +
+ " protocol_data: [ ]\n" +
+ " trunk_mode: false\n" +
+ (properties.has(DESCRIPTION) ?
+ " description: " + childElement(properties, DESCRIPTION).getAsString() + "\n" : "") +
+ " requirements:\n" +
+ " - virtual_binding: " + vdu + "\n", 2);
+ }
+
+ private String buildVolume(String nodeName, JsonObject volume) {
+ return indent(nodeName + ":\n" +
+ " type: tosca.nodes.nfv.Vdu.VirtualStorage\n" +
+ " properties:\n" +
+ " type_of_storage: volume\n" +
+ " size_of_storage: " + trimUnit(childElement(child(volume, PROPERTIES), "size_of_storage").getAsString()) + "\n", 2);
+ }
+
+ private String buildVl(JsonObject vlProperties, String name) {
+ return indent(name + ":\n" +
+ " type: tosca.nodes.nfv.VnfVirtualLink\n" +
+ " properties:\n" +
+ " connectivity_type:\n" +
+ " layer_protocol: [ " + childElement(child(vlProperties, "connectivity_type"), "layer_protocol").getAsString() + " ]\n" +
+ " flow_pattern: " + childElement(child(vlProperties, "connectivity_type"), "flow_pattern").getAsString() + "\n" +
+ " vl_profile:\n" +
+ " max_bit_rate_requirements:\n" +
+ " root: " + Integer.MAX_VALUE + "\n" + //FIXME GAP IN CBAM TEMPLATE
+ " leaf: " + Integer.MAX_VALUE + "\n" + //FIXME GAP IN CBAM TEMPLATE
+ " min_bit_rate_requirements:\n" +
+ " root: 0\n" + //FIXME GAP IN CBAM TEMPLATE
+ " leaf: 0\n", 2); //FIXME GAP IN CBAM TEMPLATE
+ }
+}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
index 406f0033..b5dd9616 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
@@ -56,6 +56,18 @@ public class OnapVnfdBuilder {
return data.trim().replaceAll("[^0-9]", "");
}
+ public static String getRequirement(JsonArray requirements, String key) {
+ for (int i = 0; i < requirements.size(); i++) {
+ JsonElement requirement = requirements.get(i);
+ Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
+ String s = next.getKey();
+ if (key.equals(s)) {
+ return next.getValue().getAsString();
+ }
+ }
+ return null;
+ }
+
/**
* @param cbamVnfd the CBAM VNFD
* @return the converted ONAP VNFD
@@ -104,8 +116,8 @@ public class OnapVnfdBuilder {
"topology_template:\n" +
" inputs:\n" +
" etsi_config:\n" +
- " type: string\n"+
- " description: The ETSI configuration\n"+
+ " type: string\n" +
+ " description: The ETSI configuration\n" +
" node_templates:\n";
}
@@ -157,7 +169,7 @@ public class OnapVnfdBuilder {
private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
- String icpName = getIcpName(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
if (icpName != null) {
return buildEcpInternal(name, icpName, nodes);
} else {
@@ -172,7 +184,7 @@ public class OnapVnfdBuilder {
private String buildEcpInternal(String ecpName, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
if (icpNode.has(REQUIREMENTS)) {
- String vdu = getVduOfIcp(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding");
//internal connection point is bound to VDU
if (vdu != null) {
return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES));
@@ -185,47 +197,11 @@ public class OnapVnfdBuilder {
return "";
}
- private String getVduOfIcp(JsonArray icpRequirements) {
- String vdu = null;
- for (int i = 0; i < icpRequirements.size(); i++) {
- JsonElement requirement = icpRequirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("virtual_binding".equals(s)) {
- vdu = next.getValue().getAsString();
- }
- }
- return vdu;
- }
-
- private String getIcpName(JsonArray requirements) {
- String icpName = null;
- for (int i = 0; i < requirements.size(); i++) {
- JsonElement requirement = requirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("internal_connection_point".equals(s)) {
- icpName = next.getValue().getAsString();
- }
- }
- return icpName;
- }
-
private String buildIcp(String name, JsonObject icp) {
if (icp.has(REQUIREMENTS)) {
JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray();
- String vdu = null;
- String vl = null;
- for (int i = 0; i < requirements.size(); i++) {
- JsonElement requirement = requirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("virtual_binding".equals(s)) {
- vdu = next.getValue().getAsString();
- } else if ("virtual_link".equals(s)) {
- vl = next.getValue().getAsString();
- }
- }
+ String vdu = getRequirement(requirements, "virtual_binding");
+ String vl = getRequirement(requirements, "virtual_link");
if (vdu == null) {
logger.warn("The {} internal connection point does not have a VDU", name);
} else if (vl == null) {
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java
new file mode 100644
index 00000000..545b2d9e
--- /dev/null
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/SupportedOnapPackageVersions.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
+
+/**
+ * The supported ONAP package versions
+ */
+public enum SupportedOnapPackageVersions {
+ V1,
+ V2
+} \ No newline at end of file
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
index 5ecd884c..95438caa 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
@@ -15,13 +15,15 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
+import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfPackageBuilder;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapR1VnfPackageBuilder;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.SupportedOnapPackageVersions;
import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,7 +47,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RequestMapping(value = BASE_URL)
public class ConverterApi {
private static Logger logger = getLogger(ConverterApi.class);
- private OnapVnfPackageBuilder vnfPackageConverter = new OnapVnfPackageBuilder();
+ private OnapR1VnfPackageBuilder vnfPackageConverter = new OnapR1VnfPackageBuilder();
/**
* Return the converted ONAP package
@@ -57,16 +59,23 @@ public class ConverterApi {
@ResponseBody
public void convert(HttpServletResponse httpResponse, HttpServletRequest request) throws IOException {
logger.info("REST: convert package");
+ SupportedOnapPackageVersions version;
+ try {
+ request.getPart("version");
+ version = SupportedOnapPackageVersions.valueOf(new String(ByteStreams.toByteArray(request.getPart("version").getInputStream()), Charsets.UTF_8));
+ } catch (Exception e) {
+ throw buildFatalFailure(logger, "Unable to determine the desired ONAP package version", e);
+ }
byte[] content;
try {
- Part part = request.getPart("fileToUpload");
- content = ByteStreams.toByteArray(part.getInputStream());
+ Part uploadedFile = request.getPart("fileToUpload");
+ content = ByteStreams.toByteArray(uploadedFile.getInputStream());
} catch (Exception e) {
throw buildFatalFailure(logger, "Unable to extract package from REST parameters", e);
}
byte[] convertedPackage;
try {
- convertedPackage = vnfPackageConverter.covert(new ByteArrayInputStream(content));
+ convertedPackage = vnfPackageConverter.covert(new ByteArrayInputStream(content), version);
} catch (Exception e) {
throw buildFatalFailure(logger, "Unable to convert VNF package", e);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
index 0993c6ee..ad02437d 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
@@ -52,7 +52,7 @@ public class CatalogManager {
* The location of the CBAM package within the ONAP package
*/
public static final String CBAM_PACKAGE_NAME_IN_ZIP = "Artifacts/Deployment/OTHER/cbam.package.zip";
- public static final String ETSI_CONFIG_NAME_IN_ZIP = "Artifacts/Deployment/OTHER/" + ETSI_CONFIG +".json";
+ public static final String ETSI_CONFIG_NAME_IN_ZIP = "Artifacts/Deployment/OTHER/" + ETSI_CONFIG + ".json";
private static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
private static final String TOSCA_VNFD_KEY = "Entry-Definitions";
@@ -112,7 +112,7 @@ public class CatalogManager {
public CatalogAdapterVnfpackage preparePackageInCbam(String vnfmId, String csarId) {
String cbamVnfdId = packageProvider.getCbamVnfdId(csarId);
DefaultApi cbamCatalogApi = cbamRestApiProvider.getCbamCatalogApi(vnfmId);
- if (!isPackageReplicated(cbamVnfdId, cbamCatalogApi)) {
+ if (!isPackageReplicated(cbamVnfdId, cbamCatalogApi)) {
try {
ByteArrayOutputStream cbamPackage = getFileInZip(new ByteArrayInputStream(packageProvider.getPackage(csarId)), CBAM_PACKAGE_NAME_IN_ZIP);
return cbamCatalogApi.create(create(parse(APPLICATION_OCTET_STREAM.toString()), cbamPackage.toByteArray())).blockingFirst();
@@ -133,15 +133,15 @@ public class CatalogManager {
/**
* Download the ETSI configuration of the VNF
+ *
* @param csarId the CSAR identifier of the package in ONAP catalog
* @return the content of the ETSI configuration
*/
- public String getEtsiConfiguration(String csarId){
+ public String getEtsiConfiguration(String csarId) {
try {
ByteArrayOutputStream etsiConfig = getFileInZip(new ByteArrayInputStream(packageProvider.getPackage(csarId)), ETSI_CONFIG_NAME_IN_ZIP);
return new String(etsiConfig.toByteArray(), Charsets.UTF_8);
- }
- catch (Exception e){
+ } catch (Exception e) {
throw buildFatalFailure(logger, "Unable to download the ETSI configuration file");
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java
index 1b6b4eb2..5342b4fd 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java
@@ -27,7 +27,7 @@ public class Constants {
public static final String BASE_URL = "/api" + BASE_SUFFIX;
public static final String LCN_URL = "/lcn";
- private Constants(){
+ private Constants() {
//use in static way
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index e36ede4e..f64ce1e0 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -18,8 +18,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import com.google.common.base.Joiner;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -30,8 +28,6 @@ import com.nokia.cbam.lcm.v32.model.ScaleDirection;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import javax.servlet.http.HttpServletResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider;
@@ -45,6 +41,7 @@ import org.yaml.snakeyaml.Yaml;
import static java.lang.Integer.parseInt;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.stream.Collectors.toList;
import static com.google.common.base.Splitter.on;
import static com.google.common.collect.Iterables.find;
@@ -302,17 +299,15 @@ public class LifecycleManager {
private AdditionalParameters convertInstantiationAdditionalParams(String csarId, Object additionalParams) {
JsonObject root = new Gson().toJsonTree(additionalParams).getAsJsonObject();
- if(root.has(PROPERTIES)){
+ if (root.has(PROPERTIES)) {
JsonObject properties = new JsonParser().parse(root.get(PROPERTIES).getAsString()).getAsJsonObject();
- if(properties.has(ETSI_CONFIG)){
+ if (properties.has(ETSI_CONFIG)) {
JsonElement etsiConfig = properties.get(ETSI_CONFIG);
return new Gson().fromJson(etsiConfig.getAsString(), AdditionalParameters.class);
+ } else {
+ logger.info("The instantiation input for VNF with {} CSAR id does not have an " + ETSI_CONFIG + " section", csarId);
}
- else{
- logger.info("The instantiation input for VNF with {} CSAR id does not have an " + ETSI_CONFIG +" section", csarId);
- }
- }
- else{
+ } else {
logger.info("The instantiation input for VNF with {} CSAR id does not have a properties section", csarId);
}
JsonObject inputs = child(root, "inputs");
@@ -333,14 +328,11 @@ public class LifecycleManager {
private Set<Map.Entry<String, JsonElement>> getAcceptableOperationParameters(String vnfdContent, String operationName) {
JsonObject root = new Gson().toJsonTree(new Yaml().load(vnfdContent)).getAsJsonObject();
JsonObject interfaces = child(child(child(root, "topology_template"), "substitution_mappings"), "interfaces");
- for (Map.Entry<String, JsonElement> categoryOfOperation : interfaces.entrySet()) {
- for (Map.Entry<String, JsonElement> operation : categoryOfOperation.getValue().getAsJsonObject().entrySet()) {
- if(operation.getKey().equals(operationName)){
- JsonObject additionalParameters = child(child(operation.getValue().getAsJsonObject(), "inputs"), "additional_parameters");
- return additionalParameters.entrySet();
- }
+ List<List<Map.Entry<String, JsonElement>>> operations = interfaces.entrySet().stream().map(m -> m.getValue().getAsJsonObject().entrySet().stream().collect(toList())).collect(toList());
+ for (Map.Entry<String, JsonElement> operation : operations.stream().flatMap(List::stream).collect(toList())) {
+ if (operation.getKey().equals(operationName)) {
+ return child(child(operation.getValue().getAsJsonObject(), "inputs"), "additional_parameters").entrySet();
}
- logger.debug("The {} operation was not found in {} interface", operationName, categoryOfOperation.getKey());
}
throw buildFatalFailure(logger, "Unable to find operation named " + operationName);
}
@@ -384,14 +376,13 @@ public class LifecycleManager {
}
}
- private void addSpecifiedExtensions(String vnfmId, String vnfId, AdditionalParameters additionalParameters){
- if(!additionalParameters.getExtensions().isEmpty()){
+ private void addSpecifiedExtensions(String vnfmId, String vnfId, AdditionalParameters additionalParameters) {
+ if (!additionalParameters.getExtensions().isEmpty()) {
ModifyVnfInfoRequest request = new ModifyVnfInfoRequest();
request.setExtensions(new ArrayList<>());
request.getExtensions().addAll(additionalParameters.getExtensions());
executeModifyVnfInfo(vnfmId, vnfId, request);
- }
- else{
+ } else {
logger.info("No extensions specified for VNF with {} identifier", vnfId);
}
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
index c4cd4342..8d5ad490 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
@@ -218,11 +218,9 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
} else {
return handleFailure(operationExecution);
}
- }
- catch(OperationMustBeAborted handledFailuire){
+ } catch (OperationMustBeAborted handledFailuire) {
throw handledFailuire;
- }
- catch (Exception e) {
+ } catch (Exception e) {
logger.warn("Unable to build affected connection points", e);
return toleratedFailure();
}
diff --git a/nokiav2/driver/src/main/resources/self.swagger.json b/nokiav2/driver/src/main/resources/self.swagger.json
index 37da1b30..2645cd0e 100644
--- a/nokiav2/driver/src/main/resources/self.swagger.json
+++ b/nokiav2/driver/src/main/resources/self.swagger.json
@@ -1046,8 +1046,14 @@
{
"description": "The CBAM VNF package",
"in": "formData",
- "name": "upfile",
+ "name": "fileToUpload",
"type": "file"
+ },
+ {
+ "description": "ONAP version of the package",
+ "in": "formData",
+ "name": "version",
+ "type": "string"
}
],
"summary": "Converts the Nokia CBAM package to ONAP package",
diff --git a/nokiav2/driver/src/main/resources/upload.html b/nokiav2/driver/src/main/resources/upload.html
index a5c686f4..ace9d2e4 100644
--- a/nokiav2/driver/src/main/resources/upload.html
+++ b/nokiav2/driver/src/main/resources/upload.html
@@ -4,9 +4,12 @@
<form action="/api/NokiaSVNFM/v1/convert" method="post" enctype="multipart/form-data">
Select CBAM package to upload:
- <input type="file" name="fileToUpload" id="fileToUpload">
+ <input type="file" name="fileToUpload" id="fileToUpload"> ONAP package version:
+ <select name="version">
+ <option value="V1">V1</option>
+ <option value="V2" selected="selected">V2</option>
+ </select>
<input type="submit" value="Upload" name="submit">
</form>
-
</body>
</html> \ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
index 8964c80b..e727602f 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
@@ -167,7 +167,7 @@ public class TestNokiaSvnfmApplication extends TestBase {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- if(calls.size() == 0){
+ if (calls.size() == 0) {
calls.add(true);
throw e2;
}
@@ -209,7 +209,7 @@ public class TestNokiaSvnfmApplication extends TestBase {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- if(calls.size() == 0){
+ if (calls.size() == 0) {
calls.add(true);
throw e2;
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java
index 4fd5a022..1ee48c8f 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForSo.java
@@ -20,10 +20,8 @@ import org.mockito.Mockito;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
import static junit.framework.TestCase.assertNotNull;
-import static org.junit.Assert.*;
public class TestSelfRegistrationManagerForSo extends TestBase {
@Test
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java
index aee54a97..4e98d2c0 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManagerForVfc.java
@@ -17,9 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import static junit.framework.TestCase.assertNotNull;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java
index fd5f112e..3d1e3c82 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java
@@ -202,7 +202,7 @@ public class TestAAIExternalSystemInfoProvider extends TestBase {
* the list of VNFMs is retrieved from AAI
*/
@Test
- public void testQueryAAIExternaSystemProvider() throws Exception{
+ public void testQueryAAIExternaSystemProvider() throws Exception {
EsrVnfmList e = new EsrVnfmList();
EsrVnfm esrVnfmItem = new EsrVnfm();
esrVnfmItem.setVnfmId(VNFM_ID);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java
index 60256049..3e585d1d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java
@@ -102,7 +102,7 @@ public class TestVfcExternalSystemInfoProvider extends TestBase {
* The VNFM identifier is loaded from property files
*/
@Test
- public void testGetVnfms(){
+ public void testGetVnfms() {
setFieldWithPropertyAnnotation(vfcExternalSystemInfoProvider, "${vnfmId}", "myVnfmId");
assertEquals(Sets.newHashSet("myVnfmId"), vfcExternalSystemInfoProvider.getVnfms());
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
index ed6375fa..0eba92dd 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java
@@ -41,7 +41,8 @@ import org.threeten.bp.OffsetDateTime;
import static java.util.Optional.empty;
import static java.util.Optional.of;
-import static junit.framework.TestCase.*;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.fail;
import static org.mockito.Mockito.*;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
import static org.springframework.test.util.ReflectionTestUtils.setField;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java
new file mode 100644
index 00000000..6916d382
--- /dev/null
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapR2VnfdBuilder.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
+
+import java.util.NoSuchElementException;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.fail;
+import static org.springframework.test.util.ReflectionTestUtils.setField;
+
+
+public class TestOnapR2VnfdBuilder extends TestBase {
+ private OnapR2VnfdBuilder packageTransformer = new OnapR2VnfdBuilder();
+
+
+ @Before
+ public void init() {
+ setField(OnapVnfdBuilder.class, "logger", logger);
+ }
+
+
+ /**
+ * Test empty VNFD conversion
+ */
+ @Test
+ public void testEmpty() {
+ assertEquals(new String(TestUtil.loadFile("unittests/packageconverter/empty.vnfd.onap.v2.yaml")), packageTransformer.toOnapVnfd(new String(TestUtil.loadFile("unittests/packageconverter/empty.vnfd.cbam.yaml"))));
+ }
+
+ /**
+ * Test all Tosca nodes conversions for successful scenario
+ */
+ @Test
+ public void testNodes() {
+ assertEquals(new String(TestUtil.loadFile("unittests/packageconverter/nodes.vnfd.onap.v2.yaml")), packageTransformer.toOnapVnfd(new String(TestUtil.loadFile("unittests/packageconverter/nodes.vnfd.cbam.yaml"))));
+ /* verify(logger).warn("The {} ecp does not have an internal connection point", "myEcpWithoutIcp");
+ verify(logger).warn("The {} ecp does not have an requirements section", "ecpWithIcpWithOutRequirements");
+ verify(logger).warn("The {} internal connection point of the {} ecp does not have a VDU", "icpWithoutVdu", "myEcpWithoutIcpWithoutVdu");
+ verify(logger).warn("The {} internal connection point of the {} ecp does not have a requirements section", "icpWithOutRequiements", "myEcpWithoutIcpWithoutIcpReq");
+ verify(logger).warn("The {} internal connection point does not have a VDU", "icpWithOutVdu");
+ verify(logger).warn("The {} internal connection point does not have a requirements section", "icpWithOutRequiements");
+ verify(logger).warn("The {} internal connection point does not have a VL", "icpWithOutVl");
+ verify(logger).warn("The {} type is not converted", "tosca.nodes.nfv.Unknown")*/
+ }
+
+ /**
+ * if a node refers to a non existing node it results in a failure
+ */
+ @Test
+ public void testInconsitentVnfd() {
+ try {
+ packageTransformer.toOnapVnfd(new String(TestUtil.loadFile("unittests/packageconverter/nodes.vnfd.inconsistent.cbam.yaml")));
+ fail();
+ } catch (NoSuchElementException e) {
+ assertEquals("The VNFD does not have a node called myComputeMissing but required by an other node", e.getMessage());
+ }
+ }
+
+}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java
index 1abb432f..55949ab0 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfPackageBuilder.java
@@ -49,7 +49,7 @@ public class TestOnapVnfPackageBuilder extends TestBase {
String expectedOnapVnfd = new OnapVnfdBuilder().toOnapVnfd(cbamVnfd);
//when
- OnapVnfPackageBuilder.main(null);
+ OnapR1VnfPackageBuilder.main(null);
//verify
assertFileInZip(bos.toByteArray(), "TOSCA-Metadata/TOSCA.meta", TestUtil.loadFile("TOSCA.meta"));
assertFileInZip(bos.toByteArray(), "MainServiceTemplate.yaml", expectedOnapVnfd.getBytes());
@@ -65,7 +65,7 @@ public class TestOnapVnfPackageBuilder extends TestBase {
*/
@Test
public void testPreventMove() {
- assertEquals("b3JnLm9uYXAudmZjLm5mdm8uZHJpdmVyLnZuZm0uc3ZuZm0ubm9raWEucGFja2FnZXRyYW5zZm9ybWVyLk9uYXBWbmZQYWNrYWdlQnVpbGRlcg==", Base64.getEncoder().encodeToString(OnapVnfPackageBuilder.class.getCanonicalName().getBytes()));
+ assertEquals("b3JnLm9uYXAudmZjLm5mdm8uZHJpdmVyLnZuZm0uc3ZuZm0ubm9raWEucGFja2FnZXRyYW5zZm9ybWVyLk9uYXBSMVZuZlBhY2thZ2VCdWlsZGVy", Base64.getEncoder().encodeToString(OnapR1VnfPackageBuilder.class.getCanonicalName().getBytes()));
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
index 8a79a33a..48d2cab0 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
@@ -73,6 +73,9 @@ public class TestConverterApi extends TestBase {
Part part = Mockito.mock(Part.class);
when(part.getInputStream()).thenReturn(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")));
when(httpRequest.getPart("fileToUpload")).thenReturn(part);
+ Part part2 = Mockito.mock(Part.class);
+ when(httpRequest.getPart("version")).thenReturn(part2);
+ when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
//when
converterApi.convert(httpResponse, httpRequest);
//verify
@@ -117,6 +120,9 @@ public class TestConverterApi extends TestBase {
public void testUnableToExtractPackageToBeConverted() throws Exception {
IOException expectedException = new IOException();
when(httpRequest.getPart("fileToUpload")).thenThrow(expectedException);
+ Part part = Mockito.mock(Part.class);
+ when(httpRequest.getPart("version")).thenReturn(part);
+ when(part.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
try {
converterApi.convert(httpResponse, httpRequest);
fail();
@@ -135,6 +141,10 @@ public class TestConverterApi extends TestBase {
Part part = Mockito.mock(Part.class);
when(part.getInputStream()).thenReturn(new ByteArrayInputStream(TestUtil.loadFile("unittests/packageconverter/cbam.package.zip")));
when(httpRequest.getPart("fileToUpload")).thenReturn(part);
+
+ Part part2 = Mockito.mock(Part.class);
+ when(httpRequest.getPart("version")).thenReturn(part2);
+ when(part2.getInputStream()).thenReturn(new ByteArrayInputStream("V1".getBytes()));
try {
converterApi.convert(httpResponse, httpRequest);
fail();
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java
index 1b34d28b..749b249d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java
@@ -64,16 +64,16 @@ public class TestSystemFunctions {
Inter inter = new Inter();
inter.start();
//wait for thread to enter waiting
- while(!entered.get() && inter.getState() != Thread.State.TIMED_WAITING && (System.currentTimeMillis() < start + 60*1000) ){
+ while (!entered.get() && inter.getState() != Thread.State.TIMED_WAITING && (System.currentTimeMillis() < start + 60 * 1000)) {
Thread.sleep(10);
}
- if(!(System.currentTimeMillis() < start + 60*1000)){
+ if (!(System.currentTimeMillis() < start + 60 * 1000)) {
throw new RuntimeException("Thread did not enter waiting state");
}
//when
inter.interrupt();
//verify
- while (exceptions.size() != 1 && (System.currentTimeMillis() < start + 60*1000)) {
+ while (exceptions.size() != 1 && (System.currentTimeMillis() < start + 60 * 1000)) {
Thread.sleep(10);
}
assertEquals(1, exceptions.size());
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
index cee26fd1..67efe84a 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
@@ -67,9 +67,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import retrofit2.Call;
import retrofit2.Response;
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.*;
import static org.mockito.Mockito.when;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getFileInZip;
@@ -250,6 +248,13 @@ public class TestBase {
throw new NoSuchElementException("The " + obj.getClass() + " does not have a filed with " + key + " annotation");
}
+ protected void assertBean(Class<?> clazz) {
+ assertEquals(1, clazz.getDeclaredConstructors().length);
+ Autowired annotation = clazz.getDeclaredConstructors()[0].getAnnotation(Autowired.class);
+ assertNotNull(annotation);
+ assertNotNull(clazz.getAnnotation(Component.class));
+ }
+
public static class VoidObservable {
boolean called = false;
ObservableFromCallable<Void> s = new ObservableFromCallable(new Callable() {
@@ -268,11 +273,4 @@ public class TestBase {
return s;
}
}
-
- protected void assertBean(Class<?> clazz){
- assertEquals(1, clazz.getDeclaredConstructors().length);
- Autowired annotation = clazz.getDeclaredConstructors()[0].getAnnotation(Autowired.class);
- assertNotNull(annotation);
- assertNotNull(clazz.getAnnotation(Component.class));
- }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java
index 8d2094b1..9eed2d8e 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java
@@ -21,12 +21,12 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider;
import static junit.framework.TestCase.assertNotNull;
-public class TestCatalogManagerForSo extends TestBase{
+public class TestCatalogManagerForSo extends TestBase {
/**
* Test bean
*/
@Test
- public void testPojo(){
+ public void testPojo() {
SdcPackageProvider sdcPackageProvider = Mockito.mock(SdcPackageProvider.class);
CatalogManagerForSo catalogManagerForSo = new CatalogManagerForSo(cbamRestApiProviderForSo, sdcPackageProvider);
assertNotNull(catalogManagerForSo);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java
index 1a21bd51..a4068d40 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java
@@ -17,17 +17,16 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcPackageProvider;
import static junit.framework.TestCase.assertNotNull;
-public class TestCatalogManagerForVfc extends TestBase{
+public class TestCatalogManagerForVfc extends TestBase {
/**
* Test bean
*/
@Test
- public void testPojo(){
+ public void testPojo() {
VfcPackageProvider vfcPackageProvider = Mockito.mock(VfcPackageProvider.class);
CatalogManagerForVfc catalogManagerForVfc = new CatalogManagerForVfc(cbamRestApiProviderForVfc, vfcPackageProvider);
assertNotNull(catalogManagerForVfc);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java
index 28e4709a..f1e1a10c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamCatalogManager.java
@@ -255,7 +255,7 @@ public class TestCbamCatalogManager extends TestBase {
* ETSI configuration extraction from the package
*/
@Test
- public void testEtsiConfigurationDownload() throws Exception{
+ public void testEtsiConfigurationDownload() throws Exception {
//given
byte[] onapPackageContent = TestUtil.loadFile("unittests/TestCbamCatalogManager.sample.csar");
when(packageProvider.getPackage(CSAR_ID)).thenReturn(onapPackageContent);
@@ -269,7 +269,7 @@ public class TestCbamCatalogManager extends TestBase {
* ETSI configuration extraction from the package
*/
@Test
- public void testEtsiConfigurationMissing() throws Exception{
+ public void testEtsiConfigurationMissing() throws Exception {
//given
byte[] onapPackageContent = TestUtil.loadFile("unittests/missing.vnfd.zip");
when(packageProvider.getPackage(CSAR_ID)).thenReturn(onapPackageContent);
@@ -277,8 +277,7 @@ public class TestCbamCatalogManager extends TestBase {
try {
cbamCatalogManager.getEtsiConfiguration(CSAR_ID);
fail();
- }
- catch (Exception e){
+ } catch (Exception e) {
assertEquals("Unable to download the ETSI configuration file", e.getMessage());
verify(logger).error("Unable to download the ETSI configuration file");
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java
index dcc6e424..24f4602d 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java
@@ -22,9 +22,9 @@ import org.mockito.Mockito;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
-public class TestCbamRestApiProviderForSo extends TestBase{
+public class TestCbamRestApiProviderForSo extends TestBase {
@Test
- public void testBean(){
+ public void testBean() {
CbamTokenProviderForSo cbamTokenProvider = Mockito.mock(CbamTokenProviderForSo.class);
AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class);
CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java
index d762bd72..9bca475a 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForVfc.java
@@ -19,13 +19,12 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import junit.framework.TestCase;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
-public class TestCbamRestApiProviderForVfc extends TestBase{
+public class TestCbamRestApiProviderForVfc extends TestBase {
@Test
- public void testBean(){
+ public void testBean() {
CbamTokenProviderForVfc cbamTokenProvider = Mockito.mock(CbamTokenProviderForVfc.class);
VfcExternalSystemInfoProvider c = Mockito.mock(VfcExternalSystemInfoProvider.class);
CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java
index 1135df98..526f2bfa 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java
@@ -18,14 +18,12 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import junit.framework.TestCase;
import org.junit.Test;
-import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
public class TestCbamTokenProviderForSo extends TestBase {
@Test
- public void testBean(){
+ public void testBean() {
AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class);
CbamTokenProviderForSo cbamTokenProviderForSo = new CbamTokenProviderForSo(aaiExternalSystemInfoProvider);
TestCase.assertNotNull(cbamTokenProviderForSo);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java
index edd54d03..696d3449 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java
@@ -19,13 +19,11 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import junit.framework.TestCase;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
public class TestCbamTokenProviderForVfc extends TestBase {
@Test
- public void testBean(){
+ public void testBean() {
VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = Mockito.mock(VfcExternalSystemInfoProvider.class);
CbamTokenProviderForVfc cbamTokenProviderForVfc = new CbamTokenProviderForVfc(vfcExternalSystemInfoProvider);
TestCase.assertNotNull(cbamTokenProviderForVfc);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java
index 58afb9bd..6244203b 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java
@@ -21,7 +21,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
public class TestConstants {
@Test
- public void useInStaticWay(){
+ public void useInStaticWay() {
TestUtil.coveragePrivateConstructorForClassesWithStaticMethodsOnly(Constants.class);
}
} \ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java
index d25859fa..c442071f 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java
@@ -15,7 +15,6 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-import junit.framework.TestCase;
import org.junit.Test;
import static junit.framework.TestCase.assertNotNull;
@@ -26,7 +25,7 @@ public class TestJobManagerForSo extends TestBase {
* Test bean
*/
@Test
- public void testPojo(){
+ public void testPojo() {
JobManagerForSo jobManagerForSo = new JobManagerForSo(cbamRestApiProviderForSo, selfRegistrationManagerForSo);
assertNotNull(jobManagerForSo);
assertBean(JobManagerForVfc.class);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java
index 1a073b58..856d7a1c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java
@@ -25,7 +25,7 @@ public class TestJobManagerForVfc extends TestBase {
* Test bean
*/
@Test
- public void testPojo(){
+ public void testPojo() {
JobManagerForVfc jobManagerForVfc = new JobManagerForVfc(cbamRestApiProviderForVfc, selfRegistrationManagerForVfc);
assertNotNull(jobManagerForVfc);
assertBean(JobManagerForVfc.class);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
index 02be5a8d..ea379e67 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
@@ -908,7 +908,7 @@ public class TestLifecycleManager extends TestBase {
fail();
} catch (RuntimeException e) {
assertEquals(expectedException, e.getCause().getCause());
- verify(logger).error("Unable to set the externalVnfmId,onapCsarId properties on the VNF with " + VNF_ID +" identifier", expectedException);
+ verify(logger).error("Unable to set the externalVnfmId,onapCsarId properties on the VNF with " + VNF_ID + " identifier", expectedException);
}
}
@@ -1198,7 +1198,7 @@ public class TestLifecycleManager extends TestBase {
notificationIsProcessedBeforeDeletingTheVnf.verify(notificationManager).waitForTerminationToBeProcessed("terminationId");
notificationIsProcessedBeforeDeletingTheVnf.verify(vnfApi).vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION);
}
-
+
/**
* test explicit forceful termination
*/
@@ -1683,23 +1683,6 @@ public class TestLifecycleManager extends TestBase {
}
}
- public static class X{
- public Map<String, String> getInputs() {
- return inputs;
- }
-
- public void setInputs(Map<String, String> inputs) {
- this.inputs = inputs;
- }
-
- @SerializedName("inputs")
- public Map<String,String> inputs = new HashMap<String,String>();
-
- public String vimId;
-
- public String properties;
- }
-
private VnfInstantiateRequest prepareInstantiationRequest(VimInfo.VimInfoTypeEnum cloudType, boolean addExtension) {
VnfInstantiateRequest instantiationRequest = new VnfInstantiateRequest();
instantiationRequest.setVnfPackageId(ONAP_CSAR_ID);
@@ -1775,7 +1758,7 @@ public class TestLifecycleManager extends TestBase {
image.setVnfdSoftwareImageId("imageId");
additionalParam.getSoftwareImages().add(image);
additionalParam.setAdditionalParams(new JsonParser().parse("{ \"a\" : \"b\" }"));
- if(addExtensions) {
+ if (addExtensions) {
VnfProperty p1 = new VnfProperty();
p1.setName("n1");
p1.setValue(Lists.newArrayList("a", "b"));
@@ -1844,7 +1827,6 @@ public class TestLifecycleManager extends TestBase {
assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
}
-
/**
* additional params of instantiation may be passed as directly attached artifact
*/
@@ -1929,4 +1911,19 @@ public class TestLifecycleManager extends TestBase {
assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
verify(logger).info("The instantiation input for VNF with {} CSAR id does not have an " + LifecycleManager.ETSI_CONFIG + " section", ONAP_CSAR_ID);
}
+
+ public static class X {
+ @SerializedName("inputs")
+ public Map<String, String> inputs = new HashMap<String, String>();
+ public String vimId;
+ public String properties;
+
+ public Map<String, String> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(Map<String, String> inputs) {
+ this.inputs = inputs;
+ }
+ }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java
index ae51dc85..42ce042c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java
@@ -15,7 +15,6 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-import junit.framework.TestCase;
import org.junit.Test;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
@@ -24,13 +23,13 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChan
import static junit.framework.TestCase.assertNotNull;
import static org.mockito.Mockito.mock;
-public class TestLifecycleManagerForSo extends TestBase{
+public class TestLifecycleManagerForSo extends TestBase {
/**
* Test bean
*/
@Test
- public void testBean(){
+ public void testBean() {
CatalogManagerForSo catalogManager = mock(CatalogManagerForSo.class);
GrantlessGrantManager grantManager = mock(GrantlessGrantManager.class);
AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = mock(AAIExternalSystemInfoProvider.class);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java
index 326476ef..730cfc7b 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java
@@ -16,22 +16,19 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import org.junit.Test;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcGrantManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
import static junit.framework.TestCase.assertNotNull;
import static org.mockito.Mockito.mock;
-public class TestLifecycleManagerForVfc extends TestBase{
+public class TestLifecycleManagerForVfc extends TestBase {
/**
* Test bean
*/
@Test
- public void testBean(){
+ public void testBean() {
CatalogManagerForVfc catalogManager = mock(CatalogManagerForVfc.class);
VfcGrantManager vfcGrantManager = mock(VfcGrantManager.class);
VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = mock(VfcExternalSystemInfoProvider.class);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
index d0657852..bfb30abd 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
@@ -23,7 +23,6 @@ import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.concurrent.*;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java
index 35a8fcee..7a282115 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManagerForVfc.java
@@ -17,7 +17,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml
index 45bfb73f..e80e9141 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.cbam.yaml
@@ -4,8 +4,14 @@ topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF
properties:
+ descriptor_id: myId
descriptor_version: '1.0'
provider: myProvider
product_name: 'myName'
software_version: '2.0'
- product_info_name: product_info_name \ No newline at end of file
+ product_info_name: product_info_name
+ capabilities:
+ deployment_flavour:
+ properties:
+ flavour_id: myFlavorId
+ description: myFlavorDescription \ No newline at end of file
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml
new file mode 100644
index 00000000..7d48b7ad
--- /dev/null
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.v2.yaml
@@ -0,0 +1,21 @@
+tosca_definitions_version: tosca_simple_profile_yaml_1_1
+
+topology_template:
+ inputs:
+ etsi_config:
+ type: string
+ description: The ETSI configuration
+ node_templates:
+ VNF:
+ type: tosca.nodes.nfv.VNF
+ properties:
+ descriptor_id: myId
+ descriptor_version: 1.0
+ provider: myProvider
+ product_name: myName
+ software_version: 2.0
+ product_info_name: product_info_name
+ vnfm_info: [ NokiaSVNFM ]
+ flavour_id: myFlavorId
+ flavour_description: myFlavorDescription
+ requirements:
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml
index 985ab276..3870605f 100644
--- a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.cbam.yaml
@@ -4,11 +4,22 @@ topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF
properties:
+ descriptor_id: Nokia~Maria DB~1.0~1.0
descriptor_version: '1.0'
provider: myProvider
product_name: 'myName'
software_version: '2.0'
product_info_name: product_info_name
+ product_info_description: Relational database, non-scalable
+ capabilities:
+ deployment_flavour:
+ properties:
+ flavour_id: scalableRouted
+ description: flavorDescription
+ vdu_profile:
+ vduNode:
+ min_number_of_instances: 3
+ max_number_of_instances: 11
node_templates:
vduNode:
type: tosca.nodes.nfv.VDU
@@ -35,19 +46,29 @@ topology_template:
type: tosca.nodes.nfv.VirtualStorage
properties:
id: myStorage1
- size_of_storage: 1G
+ size_of_storage: 1 GB
myStorage2:
type: tosca.nodes.nfv.VirtualStorage
properties:
id: myStorage2
- size_of_storage: 2G
+ size_of_storage: 2 GB
myNetwork1:
type: tosca.nodes.nfv.VL
+ properties:
+ connectivity_type:
+ layer_protocol: ipv4
+ flow_pattern: mesh
+ description: myDescription
myNetwork2:
type: tosca.nodes.nfv.VL
+ properties:
+ connectivity_type:
+ layer_protocol: ipv4
+ flow_pattern: mesh
+ description: myDescription
icpWithOutEcp:
type: tosca.nodes.nfv.ICP
diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml
new file mode 100644
index 00000000..fe0ccf4c
--- /dev/null
+++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.v2.yaml
@@ -0,0 +1,133 @@
+tosca_definitions_version: tosca_simple_profile_yaml_1_1
+
+topology_template:
+ inputs:
+ etsi_config:
+ type: string
+ description: The ETSI configuration
+ node_templates:
+ VNF:
+ type: tosca.nodes.nfv.VNF
+ properties:
+ descriptor_id: Nokia~Maria DB~1.0~1.0
+ descriptor_version: 1.0
+ provider: myProvider
+ product_name: myName
+ software_version: 2.0
+ product_info_name: product_info_name
+ product_info_description: Relational database, non-scalable
+ vnfm_info: [ NokiaSVNFM ]
+ flavour_id: scalableRouted
+ flavour_description: flavorDescription
+ requirements:
+ - virtual_link:
+ capability: tosca.capabilities.nfv.VirtualLinkable
+ node: myNetwork2
+ - virtual_link:
+ capability: tosca.capabilities.nfv.VirtualLinkable
+ node: myNetwork1
+ vduNode:
+ type: tosca.nodes.nfv.Vdu.Compute
+ properties:
+ name: vduNode
+ description: myVduDesc
+ configurable_properties:
+ vdu_profile:
+ min_number_of_instances: 3
+ max_number_of_instances: 11
+ capabilities:
+ virtual_compute:
+ properties:
+ virtual_memory:
+ virtual_mem_size: 8192 MB
+ virtual_cpu:
+ num_virtual_cpu: 4
+ requirements:
+ - virtual_storage:
+ capability: tosca.capabilities.nfv.VirtualStorage
+ node: myStorage1
+ - virtual_storage:
+ capability: tosca.capabilities.nfv.VirtualStorage
+ node: myStorage2
+ myStorage1:
+ type: tosca.nodes.nfv.Vdu.VirtualStorage
+ properties:
+ type_of_storage: volume
+ size_of_storage: 1 GB
+ myStorage2:
+ type: tosca.nodes.nfv.Vdu.VirtualStorage
+ properties:
+ type_of_storage: volume
+ size_of_storage: 2 GB
+ myNetwork1:
+ type: tosca.nodes.nfv.VnfVirtualLink
+ properties:
+ connectivity_type:
+ layer_protocol: [ ipv4 ]
+ flow_pattern: mesh
+ vl_profile:
+ max_bit_rate_requirements:
+ root: 2147483647
+ leaf: 2147483647
+ min_bit_rate_requirements:
+ root: 0
+ leaf: 0
+ myNetwork2:
+ type: tosca.nodes.nfv.VnfVirtualLink
+ properties:
+ connectivity_type:
+ layer_protocol: [ ipv4 ]
+ flow_pattern: mesh
+ vl_profile:
+ max_bit_rate_requirements:
+ root: 2147483647
+ leaf: 2147483647
+ min_bit_rate_requirements:
+ root: 0
+ leaf: 0
+ icpWithOutEcp:
+ type: tosca.nodes.nfv.VduCp
+ properties:
+ layer_protocol: [ ipv4 ]
+ description: myDescription
+ protocol_data: []
+ trunk_mode: false
+ requirements:
+ - virtual_binding: vduNode
+ - virtual_link: myNetwork1
+ icpWithEcp:
+ type: tosca.nodes.nfv.VduCp
+ properties:
+ layer_protocol: [ ipv4 ]
+ description: myDescription
+ protocol_data: []
+ trunk_mode: false
+ requirements:
+ - virtual_binding: vduNode
+ - virtual_link: myNetwork1
+ icpWithOutDescription:
+ type: tosca.nodes.nfv.VduCp
+ properties:
+ layer_protocol: [ ipv4 ]
+ protocol_data: []
+ trunk_mode: false
+ requirements:
+ - virtual_binding: vduNode
+ - virtual_link: myNetwork1
+ myEcp:
+ type: tosca.nodes.nfv.VduCp
+ properties:
+ layer_protocol: [ ipv4 ]
+ protocol_data: [ ]
+ trunk_mode: false
+ description: myDescription
+ requirements:
+ - virtual_binding: vduNode
+ myEcpWithDescription:
+ type: tosca.nodes.nfv.VduCp
+ properties:
+ layer_protocol: [ ipv4 ]
+ protocol_data: [ ]
+ trunk_mode: false
+ requirements:
+ - virtual_binding: vduNode