Merge "modify healVnf vmid"
authorGao Weitao <victor.gao@huawei.com>
Thu, 24 May 2018 08:45:55 +0000 (08:45 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 24 May 2018 08:45:55 +0000 (08:45 +0000)
34 files changed:
nokiav2/docs/.gitignore
nokiav2/docs/sample/vnfm.instantiation.request.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple/cbam.instantiation.request.json
nokiav2/docs/sampleVnfs/simple/etsi_config.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple/simple.csar
nokiav2/docs/sampleVnfs/simple/vfc.ns.instantiation.request.direct.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simpleDual/cbam.instantiation.request.json
nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar
nokiav2/docs/sampleVnfs/simpleDual/vfc.ns.instantiation.request.direct.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/cbam.instantiation.request.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/etsi_config.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.create.request.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.heal.request.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.direct.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.json [new file with mode: 0644]
nokiav2/docs/sampleVnfs/simple_cmcc/vfc.vnf.scale.request.json [new file with mode: 0644]
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIExternalSystemInfoProvider.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.yaml
nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.yaml
nokiav2/generatedapis/pom.xml

index a96ddfc..bd19fff 100644 (file)
@@ -1,3 +1,4 @@
 _build
 .DS_Store
 internal.rst
+ims
diff --git a/nokiav2/docs/sample/vnfm.instantiation.request.json b/nokiav2/docs/sample/vnfm.instantiation.request.json
new file mode 100644 (file)
index 0000000..8b111b2
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "vnfInstanceName": "vnfc3bc829b-6057-4001-ad04-7c6",
+  "extVirtualLink": [],
+  "vnfPackageId": "c3bc829b-6057-4001-ad04-7c6bfdf30138",
+  "additionalParam": {
+    "inputs": {
+      "location": "Nokia_RegionOne"
+    },
+    "extVirtualLinks": [],
+    "properties": "{\"etsi_config\": \"{'zones': [{'resourceId': 'compute-a', 'id': 'zoneInfoId'}], 'extVirtualLinks': [{'resourceId': 'pub_net', 'extCps': [{'cpdId': 'universal_ecp'}]}], 'vimType': 'OPENSTACK_V3_INFO', 'instantiationLevel': 'default', 'softwareImages': [{'vnfdSoftwareImageId': 'server_image', 'resourceId': 'ubuntu.16.04'}], 'computeResourceFlavours': [{'resourceId': 'm1.small', 'vnfdVirtualComputeDescId': 'server_compute'}], 'flavourId': 'scalable'}\", \"id\": \"c3bc829b-6057-4001-ad04-7c6bfdf30138\", \"availability_zone_max_count\": \"1\"}",
+    "vimId": "Nokia_RegionOne"
+  },
+  "vnfDescriptorId": "c3bc829b-6057-4001-ad04-7c6bfdf30138"
+}
\ No newline at end of file
index 5ec6acb..a85ca0a 100644 (file)
     "vims": [
         {
             "accessInfo": {
-                "username": "develadm", 
-                "tenant": "devel", 
-                "password": "develpass",
+                "username": "<username>",
+                "tenant": "<tenantName>",
+                "password": "<password>",
                 "region": "RegionOne"
-            }, 
+            },
             "interfaceInfo": {
-                "endpoint": "https://10.41.49.107:5000/v2.0/",
+                "endpoint": "https://<keyStoneIp>:5000/v2.0/",
                 "trustedCertificates": [],
                 "skipCertificateVerification": true,
-                "skipCertificateHostnameCheck": true 
+                "skipCertificateHostnameCheck": true
             },
             "vimInfoType": "OPENSTACK_V2_INFO",
             "id": "vim_id"
         }
-   ],
+    ],
     "instantiationLevelId": "default"
 }
diff --git a/nokiav2/docs/sampleVnfs/simple/etsi_config.json b/nokiav2/docs/sampleVnfs/simple/etsi_config.json
new file mode 100644 (file)
index 0000000..a0cff01
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "extensions": [
+    {
+      "name": "myNameKey",
+      "value": "myName"
+    }
+  ],
+  "computeResourceFlavours": [
+    {
+      "vnfdVirtualComputeDescId": "server_compute",
+      "resourceId": "m1.small"
+    }
+  ],
+  "extVirtualLinks": [
+    {
+      "extCps": [
+        {
+          "cpdId": "universal_ecp"
+        }
+      ],
+      "resourceId": "pub_net"
+    }
+  ],
+  "zones": [
+    {
+      "resourceId": "compute-a",
+      "id": "zoneInfoId"
+    }
+  ],
+  "flavourId": "scalable",
+  "vimType": "OPENSTACK_V3_INFO",
+  "instantiationLevel": "default",
+  "softwareImages": [
+    {
+      "resourceId": "ubuntu.16.04",
+      "vnfdSoftwareImageId": "server_image"
+    }
+  ]
+}
\ No newline at end of file
index da3637f..a3726c1 100644 (file)
Binary files a/nokiav2/docs/sampleVnfs/simple/simple.csar and b/nokiav2/docs/sampleVnfs/simple/simple.csar differ
diff --git a/nokiav2/docs/sampleVnfs/simple/vfc.ns.instantiation.request.direct.json b/nokiav2/docs/sampleVnfs/simple/vfc.ns.instantiation.request.direct.json
new file mode 100644 (file)
index 0000000..811f13a
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "nsInstanceId": "23fd3ae5-c261-4662-9fcd-35107d33954f",
+  "additionalParamForNs": {
+    "location": "Nokia_RegionOne"
+  }
+}
\ No newline at end of file
index 5ec6acb..16fc4d1 100644 (file)
     "vims": [
         {
             "accessInfo": {
-                "username": "develadm", 
-                "tenant": "devel", 
-                "password": "develpass",
+                "username": "<username>",
+                "tenant": "<tenantName>",
+                "password": "<password>",
                 "region": "RegionOne"
             }, 
             "interfaceInfo": {
-                "endpoint": "https://10.41.49.107:5000/v2.0/",
+                "endpoint": "https://<keyStoneIp>:5000/v2.0/",
                 "trustedCertificates": [],
                 "skipCertificateVerification": true,
                 "skipCertificateHostnameCheck": true 
index 7b0b57f..3a43b78 100644 (file)
Binary files a/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar and b/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar differ
diff --git a/nokiav2/docs/sampleVnfs/simpleDual/vfc.ns.instantiation.request.direct.json b/nokiav2/docs/sampleVnfs/simpleDual/vfc.ns.instantiation.request.direct.json
new file mode 100644 (file)
index 0000000..452b10b
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "nsInstanceId": "b65572a1-4f2e-4787-950d-bb489e970623",
+  "additionalParamForNs": {
+    "location": "Nokia_RegionOne"
+  }
+}
\ No newline at end of file
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.instantiation.request.json b/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.instantiation.request.json
new file mode 100644 (file)
index 0000000..0e0dcd2
--- /dev/null
@@ -0,0 +1,3 @@
+{
+
+}
\ No newline at end of file
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/etsi_config.json b/nokiav2/docs/sampleVnfs/simple_cmcc/etsi_config.json
new file mode 100644 (file)
index 0000000..ef3bce5
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "computeResourceFlavours": [
+    {
+      "vnfdVirtualComputeDescId": "server_compute",
+      "resourceId": "m1.small"
+    }
+  ],
+  "extVirtualLinks": [
+    {
+      "extCps": [
+        {
+          "cpdId": "universal_ecp"
+        }
+      ],
+      "resourceId": "oam-nokia"
+    }
+  ],
+  "zones": [
+    {
+      "resourceId": "nova",
+      "id": "zoneInfoId"
+    }
+  ],
+  "flavourId": "scalable",
+  "vimType": "OPENSTACK_V3_INFO",
+  "instantiationLevel": "default",
+  "softwareImages": [
+    {
+      "resourceId": "ubuntu.16.04",
+      "vnfdSoftwareImageId": "server_image"
+    }
+  ],
+  "extensions" : [ { "name": "myNameKey", "value": "myName"} ]
+}
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar
new file mode 100644 (file)
index 0000000..48a38b8
Binary files /dev/null and b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar differ
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.create.request.json b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.create.request.json
new file mode 100644 (file)
index 0000000..d6e9d2d
--- /dev/null
@@ -0,0 +1,9 @@
+{
+    "nsName": "simple_20180517_1",
+    "csarId": "58b0320f-f4f1-421f-ba38-2dda1f2d6484",
+    "context": {
+        "globalCustomerId" : "Demonstration",
+        "serviceType" :  "Database"
+    },
+    "description": "string"
+}
\ No newline at end of file
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.heal.request.json b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.heal.request.json
new file mode 100644 (file)
index 0000000..49c7921
--- /dev/null
@@ -0,0 +1,13 @@
+{
+  "healVnfData": {
+    "vnfInstanceId": "98dfd286-e4dc-437b-9607-15fb3964485d",
+    "cause": "cause",
+    "additionalParams": {
+      "action": "auto",
+      "actionvminfo": {
+        "vmid": "95a8f4bd-3384-48b9-8c97-8493ee6e7535",
+        "vmname": "CBAM-59fa6b5b2c004c689ed30df5eeff69ef-simple-0"
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.direct.json b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.direct.json
new file mode 100644 (file)
index 0000000..4182009
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "nsInstanceId": "601f68d2-b1cd-4c47-8af9-1a781eb5fa2a",
+  "additionalParamForNs": {
+    "location": "NokiaNonAdmin_RegionOne"
+  }
+}
\ No newline at end of file
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.json b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.json
new file mode 100644 (file)
index 0000000..01f3793
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "nsInstanceId": "601f68d2-b1cd-4c47-8af9-1a781eb5fa2a",
+  "additionalParamForNs": {
+    "location": "NokiaNonAdmin_RegionOne",
+    "45dd6e04-34d4-452f-8eff-d944c2b8e075": "{ \"computeResourceFlavours\": [ { \"vnfdVirtualComputeDescId\": \"server_compute\", \"resourceId\": \"m1.small\" } ], \"extVirtualLinks\": [ { \"extCps\": [ { \"cpdId\": \"universal_ecp\" } ], \"resourceId\": \"oam-nokia\" } ], \"zones\": [ { \"resourceId\": \"nova\", \"id\": \"zoneInfoId\" } ], \"flavourId\": \"scalable\", \"vimType\": \"OPENSTACK_V3_INFO\", \"instantiationLevel\": \"default\", \"softwareImages\": [ { \"resourceId\": \"ubuntu.16.04\", \"vnfdSoftwareImageId\": \"server_image\" } ] }"
+  }
+}
\ No newline at end of file
diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.vnf.scale.request.json b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.vnf.scale.request.json
new file mode 100644 (file)
index 0000000..3140f4a
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "scaleVnfData" :
+  {
+    "type" : "SCALE_OUT",
+    "aspectId"  : "simpleAspect",
+    "numberOfSteps" : "1"
+  }
+}
\ No newline at end of file
index 17060d6..123f263 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
 import com.nokia.cbam.lcn.v32.api.SubscriptionsApi;
@@ -110,6 +111,7 @@ public class SelfRegistrationManager {
      *
      * @param vnfmId the identifier of the VNFM
      */
+    @VisibleForTesting
     public void assureSubscription(String vnfmId) {
         if (!vnfmIdToSubscriptionId.containsKey(vnfmId)) {
             subscribeToLcn(vnfmId);
index d0df8a8..164d3a2 100644 (file)
@@ -101,6 +101,9 @@ public class GenericVnfManager extends AbstractManager {
         if (nsId.isPresent()) {
             addSingletonRelation(vnf.getRelationshipList(), linkToNs(nsId.get()));
         }
+        else{
+            logger.warn("Not linking VNF with {} identifier to any NS", vnfId);
+        }
         aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst();
     }
 
index 6a20bc2..406f003 100644 (file)
@@ -102,6 +102,10 @@ public class OnapVnfdBuilder {
                 "  name: " + properties.get("product_name").getAsString() + "\n" +
                 "  vnfdVersion: " + descriptorVersion + "\n\n" +
                 "topology_template:\n" +
+                "  inputs:\n" +
+                "    etsi_config:\n" +
+                "      type: string\n"+
+                "      description: The ETSI configuration\n"+
                 "  node_templates:\n";
     }
 
index b4e5915..116420d 100644 (file)
@@ -81,7 +81,7 @@ public class CbamUtils {
         return new OperationMustBeAborted(msg);
     }
 
-    private static class OperationMustBeAborted extends RuntimeException {
+    public static class OperationMustBeAborted extends RuntimeException {
         OperationMustBeAborted(String msg) {
             super(msg);
         }
index c0b5c5b..5895108 100644 (file)
@@ -31,6 +31,7 @@ public class AdditionalParameters {
     private List<ExtManagedVirtualLinkData> extManagedVirtualLinks = new ArrayList<>();
     private Map<String, List<NetworkAddress>> externalConnectionPointAddresses = new HashMap<>();
     private List<ExtVirtualLinkData> extVirtualLinks = new ArrayList<>();
+    private List<VnfProperty> extensions = new ArrayList<>();
     private Object additionalParams;
     private String domain;
 
@@ -158,6 +159,28 @@ public class AdditionalParameters {
         this.extVirtualLinks = extVirtualLinks;
     }
 
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
+    /**
+     * @return the extensions of the VNF modifiable attributes
+     */
+    public List<VnfProperty> getExtensions() {
+        return extensions;
+    }
+
+    /**
+     * @param extensions the extensions of the VNF modifiable attributes
+     */
+    public void setExtensions(List<VnfProperty> extensions) {
+        this.extensions = extensions;
+    }
+
     @Override
     //generated code. This is the recommended way to formulate equals
     @SuppressWarnings({"squid:S00122", "squid:S1067"})
@@ -174,20 +197,19 @@ public class AdditionalParameters {
                 Objects.equals(extManagedVirtualLinks, that.extManagedVirtualLinks) &&
                 Objects.equals(externalConnectionPointAddresses, that.externalConnectionPointAddresses) &&
                 Objects.equals(extVirtualLinks, that.extVirtualLinks) &&
+                Objects.equals(extensions, that.extensions) &&
                 Objects.equals(additionalParams, that.additionalParams);
     }
 
     @Override
     public int hashCode() {
-
-        return Objects.hash(vimType, domain, instantiationLevel, computeResourceFlavours, zones, softwareImages, extManagedVirtualLinks, externalConnectionPointAddresses, extVirtualLinks, additionalParams);
+        return Objects.hash(vimType, domain, instantiationLevel, computeResourceFlavours, zones, softwareImages, extManagedVirtualLinks, externalConnectionPointAddresses, extVirtualLinks, extensions, additionalParams);
     }
 
     @Override
     public String toString() {
         return "AdditionalParameters{" +
                 "vimType=" + vimType +
-                ", domain='" + domain + '\'' +
                 ", instantiationLevel='" + instantiationLevel + '\'' +
                 ", computeResourceFlavours=" + computeResourceFlavours +
                 ", zones=" + zones +
@@ -195,15 +217,9 @@ public class AdditionalParameters {
                 ", extManagedVirtualLinks=" + extManagedVirtualLinks +
                 ", externalConnectionPointAddresses=" + externalConnectionPointAddresses +
                 ", extVirtualLinks=" + extVirtualLinks +
+                ", extensions=" + extensions +
                 ", additionalParams=" + additionalParams +
+                ", domain='" + domain + '\'' +
                 '}';
     }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
 }
\ No newline at end of file
index b826931..5d65050 100644 (file)
@@ -17,6 +17,7 @@
 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
 
 
+import com.google.common.base.Joiner;
 import com.google.gson.Gson;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -43,7 +44,9 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 
 import static com.google.common.base.Splitter.on;
 import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.transform;
 import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Ordering.natural;
 import static com.google.common.collect.Sets.newHashSet;
 import static com.nokia.cbam.lcm.v32.model.InstantiationState.INSTANTIATED;
 import static com.nokia.cbam.lcm.v32.model.OperationStatus.FINISHED;
@@ -67,6 +70,8 @@ public class LifecycleManager {
      */
     public static final String EXTERNAL_VNFM_ID = "externalVnfmId";
     public static final String SCALE_OPERATION_NAME = "scale";
+    public static final String ETSI_CONFIG = "etsi_config";
+    public static final String PROPERTIES = "properties";
     private static Logger logger = getLogger(LifecycleManager.class);
     private final CatalogManager catalogManager;
     private final IGrantManager grantManager;
@@ -214,6 +219,7 @@ public class LifecycleManager {
     @SuppressWarnings("squid:S00107") //wrapping them into an object makes the code less readable
     private void instantiateVnf(String vnfmId, List<ExtVirtualLinkInfo> extVirtualLinkInfos, AdditionalParameters additionalParameters, String onapVnfdId, String vnfmVnfdId, String vnfId, String vimId, JobInfo jobInfo) {
         String vnfdContent = catalogManager.getCbamVnfdContent(vnfmId, vnfmVnfdId);
+        addSpecifiedExtensions(vnfmId, vnfId, additionalParameters);
         GrantVNFResponseVim vim = grantManager.requestGrantForInstantiate(vnfmId, vnfId, vimId, onapVnfdId, additionalParameters.getInstantiationLevel(), vnfdContent, jobInfo.getJobId());
         handleBackwardIncompatibleApiChangesInVfc(vim);
         VimInfo vimInfo = vimInfoProvider.getVimInfo(vim.getVimId());
@@ -291,9 +297,23 @@ public class LifecycleManager {
     }
 
     private AdditionalParameters convertInstantiationAdditionalParams(String csarId, Object additionalParams) {
-        JsonObject inputs = child(new Gson().toJsonTree(additionalParams).getAsJsonObject(), "inputs");
+        JsonObject root = new Gson().toJsonTree(additionalParams).getAsJsonObject();
+        if(root.has(PROPERTIES)){
+            JsonObject properties = new JsonParser().parse(root.get(PROPERTIES).getAsString()).getAsJsonObject();
+            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 a properties section", csarId);
+        }
+        JsonObject inputs = child(root, "inputs");
         if (!inputs.has(csarId)) {
-            throw buildFatalFailure(logger, "The additional parameter section does not contain setting for VNF with " + csarId + " CSAR id");
+            throw buildFatalFailure(logger, "The additional parameter section does not contain settings for VNF with " + csarId + " CSAR id");
         }
         JsonElement additionalParamsForVnf = new JsonParser().parse(inputs.get(csarId).getAsString());
         return new Gson().fromJson(additionalParamsForVnf, AdditionalParameters.class);
@@ -302,7 +322,7 @@ public class LifecycleManager {
     private String getFlavorId(String vnfdContent) {
         JsonObject root = new Gson().toJsonTree(new Yaml().load(vnfdContent)).getAsJsonObject();
         JsonObject capabilities = child(child(child(root, "topology_template"), "substitution_mappings"), "capabilities");
-        JsonObject deploymentFlavorProperties = child(child(capabilities, "deployment_flavour"), "properties");
+        JsonObject deploymentFlavorProperties = child(child(capabilities, "deployment_flavour"), PROPERTIES);
         return childElement(deploymentFlavorProperties, "flavour_id").getAsString();
     }
 
@@ -330,21 +350,37 @@ public class LifecycleManager {
 
     private void addVnfdIdToVnfModifyableAttributeExtensions(String vnfmId, String vnfId, String onapCsarId) {
         ModifyVnfInfoRequest request = new ModifyVnfInfoRequest();
+        request.setExtensions(new ArrayList<>());
         VnfProperty onapCsarIdProperty = new VnfProperty();
         onapCsarIdProperty.setName(ONAP_CSAR_ID);
         onapCsarIdProperty.setValue(onapCsarId);
-        request.setExtensions(new ArrayList<>());
         request.getExtensions().add(onapCsarIdProperty);
         VnfProperty externalVnfmIdProperty = new VnfProperty();
         externalVnfmIdProperty.setName(EXTERNAL_VNFM_ID);
         externalVnfmIdProperty.setValue(vnfmId);
         request.getExtensions().add(externalVnfmIdProperty);
-        request.setVnfConfigurableProperties(null);
+        executeModifyVnfInfo(vnfmId, vnfId, request);
+    }
+
+    private void executeModifyVnfInfo(String vnfmId, String vnfId, ModifyVnfInfoRequest request) {
         try {
             OperationExecution operationExecution = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdPatch(vnfId, request, NOKIA_LCM_API_VERSION).blockingFirst();
             waitForOperationToFinish(vnfmId, vnfId, operationExecution.getId());
         } catch (Exception e) {
-            throw buildFatalFailure(logger, "Unable to set the " + ONAP_CSAR_ID + " property on the VNF", e);
+            String properties = Joiner.on(",").join(natural().sortedCopy(transform(request.getExtensions(), VnfProperty::getName)));
+            throw buildFatalFailure(logger, "Unable to set the " + properties + " properties on the VNF with " + vnfId + " identifier", e);
+        }
+    }
+
+    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{
+            logger.info("No extensions specified for VNF with {} identifier", vnfId);
         }
     }
 
index d237885..1bda9a3 100644 (file)
@@ -17,7 +17,6 @@
 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
 
 
-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.LifecycleChangeNotificationManagerForVfc;
index 9b49734..c4cd434 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Optional;
 import java.util.Set;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.OperationMustBeAborted;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager;
@@ -210,15 +211,20 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
                 JsonObject operationResult = root.getAsJsonObject().get("operationResult").getAsJsonObject();
                 if (isAbsent(operationResult, "cbam_pre") ||
                         isAbsent(operationResult, "cbam_post")) {
-                    return handleFailure(operationExecution, null);
+                    return handleFailure(operationExecution);
                 } else {
                     return of(new Gson().fromJson(operationResult, ReportedAffectedConnectionPoints.class));
                 }
             } else {
-                return handleFailure(operationExecution, null);
+                return handleFailure(operationExecution);
             }
-        } catch (Exception e) {
-            return handleFailure(operationExecution, e);
+        }
+        catch(OperationMustBeAborted handledFailuire){
+            throw handledFailuire;
+        }
+        catch (Exception e) {
+            logger.warn("Unable to build affected connection points", e);
+            return toleratedFailure();
         }
     }
 
@@ -226,15 +232,16 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
         return !operationResult.has(key) || !operationResult.get(key).isJsonArray();
     }
 
-    private Optional<ReportedAffectedConnectionPoints> handleFailure(OperationExecution operationExecution, Exception e) {
+    private Optional<ReportedAffectedConnectionPoints> handleFailure(OperationExecution operationExecution) {
         if (operationExecution.getStatus() == OperationStatus.FAILED) {
-            logger.warn("The operation failed and the affected connection points were not reported");
-            return empty();
+            return toleratedFailure();
         } else {
-            if (e != null) {
-                throw buildFatalFailure(logger, PROBLEM, e);
-            }
             throw buildFatalFailure(logger, PROBLEM);
         }
     }
+
+    private Optional<ReportedAffectedConnectionPoints> toleratedFailure() {
+        logger.warn("The operation failed and the affected connection points were not reported");
+        return empty();
+    }
 }
index d1e2dea..b082dbd 100644 (file)
@@ -234,6 +234,7 @@ public class TestSelfRegistrationManager extends TestBase {
             return buildObservable(subscription);
         });
         selfRegistrationManager.assureSubscription(VNFM_ID);
+        selfRegistrationManager.assureSubscription(VNFM_ID);
         when(jobManager.hasOngoingJobs()).thenReturn(false);
         when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
         VoidObservable MSB_DELETE = new VoidObservable();
index 912a220..fd5f112 100644 (file)
@@ -16,6 +16,7 @@
 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct;
 
 import java.util.ArrayList;
+import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -24,6 +25,7 @@ import org.onap.aai.api.ExternalSystemApi;
 import org.onap.aai.model.CloudRegion;
 import org.onap.aai.model.EsrSystemInfo;
 import org.onap.aai.model.EsrVnfm;
+import org.onap.aai.model.EsrVnfmList;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
 import org.onap.vnfmdriver.model.VimInfo;
 import org.onap.vnfmdriver.model.VnfmInfo;
@@ -195,4 +197,21 @@ public class TestAAIExternalSystemInfoProvider extends TestBase {
             assertEquals(expectedException, e.getCause());
         }
     }
+
+    /**
+     * the list of VNFMs is retrieved from AAI
+     */
+    @Test
+    public void testQueryAAIExternaSystemProvider() throws Exception{
+        EsrVnfmList e = new EsrVnfmList();
+        EsrVnfm esrVnfmItem = new EsrVnfm();
+        esrVnfmItem.setVnfmId(VNFM_ID);
+        e.addEsrVnfmItem(esrVnfmItem);
+        when(externalSystemApi.getExternalSystemEsrVnfmList()).thenReturn(buildObservable(e));
+        //when
+        Set<String> vnfms = aaiExternalSystemInfoProvider.getVnfms();
+        //verify
+        assertEquals(1, vnfms.size());
+        assertEquals(VNFM_ID, vnfms.iterator().next());
+    }
 }
\ No newline at end of file
index 5ade389..b4783b4 100644 (file)
@@ -17,10 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification;
 
 import com.nokia.cbam.lcm.v32.model.VnfInfo;
 import io.reactivex.Observable;
-import java.util.HashSet;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicLong;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,6 +36,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
 
 import static java.lang.Boolean.TRUE;
+import static java.util.Optional.empty;
 import static java.util.Optional.of;
 
 import static junit.framework.TestCase.assertEquals;
@@ -140,8 +138,10 @@ public class TestGenericVnfManager extends TestBase {
         when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
         when(networkApi.createOrUpdateNetworkGenericVnfsGenericVnf(eq(VNF_ID), payload.capture())).thenReturn(VOID_OBSERVABLE.value());
         vnfInfo.setName("vnfName");
+        vnfInAaai.setRelationshipList(new ArrayList<>());
+        vnfInAaai.getRelationshipList().add(new Relationship());
         //when
-        genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, of("nsId"));
+        genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, empty());
         //verify
         GenericVnf vnfSentToAai = payload.getValue();
         assertEquals(VNF_ID, vnfSentToAai.getVnfId());
@@ -152,6 +152,7 @@ public class TestGenericVnfManager extends TestBase {
         assertEquals("vnfName", vnfSentToAai.getVnfName());
         verify(systemFunctions, never()).sleep(anyLong());
         VOID_OBSERVABLE.assertCalled();
+        assertEquals(1, vnfInAaai.getRelationshipList().size());
         verify(networkApi, times(1)).getNetworkGenericVnfsGenericVnf(VNF_ID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
     }
 
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
new file mode 100644 (file)
index 0000000..58afb9b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.vnfm;
+
+import org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
+
+public class TestConstants {
+
+    @Test
+    public void useInStaticWay(){
+        TestUtil.coveragePrivateConstructorForClassesWithStaticMethodsOnly(Constants.class);
+    }
+}
\ No newline at end of file
index 026e65d..d91c847 100644 (file)
@@ -26,6 +26,7 @@ import io.reactivex.Observable;
 import java.nio.file.Paths;
 import java.util.*;
 import javax.servlet.http.HttpServletResponse;
+import org.assertj.core.util.Lists;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
@@ -177,8 +178,7 @@ public class TestLifecycleManager extends TestBase {
     @Test
     public void testInstantiation() throws Exception {
         //given
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
-
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, true);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -252,18 +252,39 @@ public class TestLifecycleManager extends TestBase {
         assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification());
         assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
 
-        assertEquals(1, actualVnfModifyRequest.getAllValues().size());
-        assertEquals(2, actualVnfModifyRequest.getValue().getExtensions().size());
-        assertEquals(LifecycleManager.ONAP_CSAR_ID, actualVnfModifyRequest.getValue().getExtensions().get(0).getName());
-        assertEquals(ONAP_CSAR_ID, actualVnfModifyRequest.getValue().getExtensions().get(0).getValue());
-        assertEquals(LifecycleManager.EXTERNAL_VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getName());
-        assertEquals(VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getValue());
+        assertEquals(2, actualVnfModifyRequest.getAllValues().size());
+        assertEquals(2, actualVnfModifyRequest.getAllValues().get(0).getExtensions().size());
+        assertEquals(LifecycleManager.ONAP_CSAR_ID, actualVnfModifyRequest.getAllValues().get(0).getExtensions().get(0).getName());
+        assertEquals(ONAP_CSAR_ID, actualVnfModifyRequest.getAllValues().get(0).getExtensions().get(0).getValue());
+        assertEquals(LifecycleManager.EXTERNAL_VNFM_ID, actualVnfModifyRequest.getAllValues().get(0).getExtensions().get(1).getName());
+        assertEquals(VNFM_ID, actualVnfModifyRequest.getAllValues().get(0).getExtensions().get(1).getValue());
+
+        assertEquals(3, actualVnfModifyRequest.getAllValues().get(1).getExtensions().size());
+
+        VnfProperty p1 = new VnfProperty();
+        p1.setName("n1");
+        p1.setValue(Lists.newArrayList("a", "b"));
+        VnfProperty p2 = new VnfProperty();
+        p2.setName("n2");
+        p2.setValue("a");
+        VnfProperty p3 = new VnfProperty();
+        p2.setName("n2");
+        JsonObject o = new JsonObject();
+        p2.setValue(o);
+        o.addProperty("a", "b");
+        assertEquals(p1, actualVnfModifyRequest.getAllValues().get(1).getExtensions().get(0));
+        assertEquals("n2", actualVnfModifyRequest.getAllValues().get(1).getExtensions().get(1).getName());
+        HashMap<String, String> expected = new HashMap<>();
+        expected.put("a", "b");
+        assertEquals(expected, actualVnfModifyRequest.getAllValues().get(1).getExtensions().get(1).getValue());
+        assertEquals(p3, actualVnfModifyRequest.getAllValues().get(1).getExtensions().get(2));
 
         //the 3.2 API does not accept empty array
         assertNull(actualVnfModifyRequest.getValue().getVnfConfigurableProperties());
         verify(jobManager).spawnJob(VNF_ID, restResponse);
         verify(logger).info(eq("Starting {} operation on VNF with {} identifier with {} parameter"), eq("creation"), eq("not yet specified"), anyString());
         verify(logger).info(eq("Starting {} operation on VNF with {} identifier with {} parameter"), eq("instantiation"), eq(VNF_ID), anyString());
+        verify(logger).info("The instantiation input for VNF with {} CSAR id does not have a properties section", ONAP_CSAR_ID);
     }
 
     /**
@@ -272,7 +293,7 @@ public class TestLifecycleManager extends TestBase {
     @Test
     public void testInstantiationWithInvalidVimType() throws Exception {
         //given
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         when(logger.isInfoEnabled()).thenReturn(false);
         //when
@@ -294,7 +315,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationV2WithSsl() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
         when(logger.isInfoEnabled()).thenReturn(false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -330,7 +351,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationV2WithoutSsl() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
 
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -357,7 +378,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationV3() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -395,7 +416,7 @@ public class TestLifecycleManager extends TestBase {
     @Test
     public void testInstantiationNoVimId() throws Exception {
         //given
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -488,7 +509,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationV3WithSsl() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -527,7 +548,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationV3WithNonSpecifiedSsl() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -564,7 +585,7 @@ public class TestLifecycleManager extends TestBase {
     public void testInstantiationV3WithNoDomain() throws Exception {
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         additionalParam.setDomain("myDomain");
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
         vimInfo.setDomain(null);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -601,7 +622,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationV3WithNoDomainFail() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
         vimInfo.setDomain(null);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -626,7 +647,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationVcloud() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO, false);
 
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -660,7 +681,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationVcloudWithSsl() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO, false);
 
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -698,7 +719,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testInstantiationVcloudWithNonSecifedSSl() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO, false);
 
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -732,7 +753,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testFailureInTheInstantiationRequest() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -758,7 +779,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testVfcFailsToSendVimId() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
 
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -785,7 +806,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testVfcFailsToSendAccessInfo() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
 
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
@@ -812,7 +833,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testFailureInTheOperationExecutionPollingDuringInstantiationRequest() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
@@ -853,7 +874,7 @@ public class TestLifecycleManager extends TestBase {
     @Test
     public void failureInVnfCreationIsPropagated() throws Exception {
         //given
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
 
         RuntimeException expectedException = new RuntimeException();
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenThrow(expectedException);
@@ -874,7 +895,7 @@ public class TestLifecycleManager extends TestBase {
     @Test
     public void failureInVnfModificationIsPropagated() throws Exception {
         //given
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
 
         RuntimeException expectedException = new RuntimeException();
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
@@ -887,7 +908,7 @@ public class TestLifecycleManager extends TestBase {
             fail();
         } catch (RuntimeException e) {
             assertEquals(expectedException, e.getCause().getCause());
-            verify(logger).error("Unable to set the onapCsarId property on the VNF", expectedException);
+            verify(logger).error("Unable to set the externalVnfmId,onapCsarId properties on the VNF with " + VNF_ID +" identifier", expectedException);
         }
     }
 
@@ -897,7 +918,7 @@ public class TestLifecycleManager extends TestBase {
      */
     @Test
     public void testFailureInQueryVimInfo() throws Exception {
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
         when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
         when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
         grantResponse.setVimId(VIM_ID);
@@ -1184,7 +1205,7 @@ public class TestLifecycleManager extends TestBase {
     @Test
     public void testMissingVnfParameters() throws Exception {
         //given
-        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO, false);
         String src = "{ \"inputs\" : { \"vnfs\" : { \"" + ONAP_CSAR_ID + "invalid" + "\" : {}}}, \"vimId\" : \"" + VIM_ID + "\"}";
         instantiationRequest.setAdditionalParam(new JsonParser().parse(src));
         //when
@@ -1192,8 +1213,8 @@ public class TestLifecycleManager extends TestBase {
             VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
             fail();
         } catch (Exception e) {
-            assertEquals("The additional parameter section does not contain setting for VNF with myOnapCsarId CSAR id", e.getMessage());
-            verify(logger).error("The additional parameter section does not contain setting for VNF with myOnapCsarId CSAR id");
+            assertEquals("The additional parameter section does not contain settings for VNF with myOnapCsarId CSAR id", e.getMessage());
+            verify(logger).error("The additional parameter section does not contain settings for VNF with myOnapCsarId CSAR id");
         }
     }
 
@@ -1665,14 +1686,33 @@ public class TestLifecycleManager extends TestBase {
         public Map<String,String> inputs = new HashMap<String,String>();
 
         public String vimId;
+
+        public String properties;
     }
 
-    private VnfInstantiateRequest prepareInstantiationRequest(VimInfo.VimInfoTypeEnum cloudType) {
+    private VnfInstantiateRequest prepareInstantiationRequest(VimInfo.VimInfoTypeEnum cloudType, boolean addExtension) {
         VnfInstantiateRequest instantiationRequest = new VnfInstantiateRequest();
         instantiationRequest.setVnfPackageId(ONAP_CSAR_ID);
         instantiationRequest.setVnfDescriptorId(ONAP_CSAR_ID);
         instantiationRequest.setVnfInstanceDescription("myDescription");
         instantiationRequest.setVnfInstanceName("vnfName");
+        externalVirtualLink.setCpdId("myCpdId");
+        externalVirtualLink.setResourceId("myNetworkProviderId");
+        externalVirtualLink.setVlInstanceId("myEVlId");
+        externalVirtualLink.setResourceSubnetId("notUsedSubnetId");
+        instantiationRequest.setExtVirtualLink(new ArrayList<>());
+        instantiationRequest.getExtVirtualLink().add(externalVirtualLink);
+        buildAdditionalParams(cloudType, addExtension);
+        String params = new Gson().toJson(additionalParam);
+        X x = new X();
+        x.inputs.put(ONAP_CSAR_ID, params);
+        x.vimId = VIM_ID;
+        JsonElement additionalParam = new Gson().toJsonTree(x);
+        instantiationRequest.setAdditionalParam(additionalParam);
+        return instantiationRequest;
+    }
+
+    private void buildAdditionalParams(VimInfo.VimInfoTypeEnum cloudType, boolean addExtensions) {
         additionalParam.setInstantiationLevel("level1");
         switch (cloudType) {
             case OPENSTACK_V2_INFO:
@@ -1713,12 +1753,6 @@ public class TestLifecycleManager extends TestBase {
         ecp2.setNumDynamicAddresses(2);
         evl.getExtCps().add(ecp2);
         additionalParam.getExtVirtualLinks().add(evl);
-        externalVirtualLink.setCpdId("myCpdId");
-        externalVirtualLink.setResourceId("myNetworkProviderId");
-        externalVirtualLink.setVlInstanceId("myEVlId");
-        externalVirtualLink.setResourceSubnetId("notUsedSubnetId");
-        instantiationRequest.setExtVirtualLink(new ArrayList<>());
-        instantiationRequest.getExtVirtualLink().add(externalVirtualLink);
         additionalParam.getExtManagedVirtualLinks().add(extManVl);
         ZoneInfo zone = new ZoneInfo();
         zone.setId("zoneId");
@@ -1731,13 +1765,22 @@ public class TestLifecycleManager extends TestBase {
         image.setVnfdSoftwareImageId("imageId");
         additionalParam.getSoftwareImages().add(image);
         additionalParam.setAdditionalParams(new JsonParser().parse("{ \"a\" : \"b\" }"));
-        String params = new Gson().toJson(additionalParam);
-        X x = new X();
-        x.inputs.put(ONAP_CSAR_ID, params);
-        x.vimId = VIM_ID;
-        JsonElement additionalParam = new Gson().toJsonTree(x);
-        instantiationRequest.setAdditionalParam(additionalParam);
-        return instantiationRequest;
+        if(addExtensions) {
+            VnfProperty p1 = new VnfProperty();
+            p1.setName("n1");
+            p1.setValue(Lists.newArrayList("a", "b"));
+            VnfProperty p2 = new VnfProperty();
+            p2.setName("n2");
+            p2.setValue("a");
+            VnfProperty p3 = new VnfProperty();
+            p2.setName("n2");
+            JsonObject o = new JsonObject();
+            p2.setValue(o);
+            o.addProperty("a", "b");
+            additionalParam.getExtensions().add(p1);
+            additionalParam.getExtensions().add(p2);
+            additionalParam.getExtensions().add(p3);
+        }
     }
 
     /**
@@ -1748,4 +1791,91 @@ public class TestLifecycleManager extends TestBase {
         assertEquals("regionId", LifecycleManager.getRegionName("cloudOwner_regionId"));
         assertEquals("cloudOwner", LifecycleManager.getCloudOwner("cloudOwner_regionId"));
     }
+
+    /**
+     * additional params of instantiation may be passed as VNF property
+     */
+    @Test
+    public void testVnfConfigurationBasedOnPackageParameters() throws Exception {
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
+        when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
+        additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
+        when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
+        grantResponse.setVimId(VIM_ID);
+        GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
+        accessInfo.setTenant(TENANT);
+        grantResponse.setAccessInfo(accessInfo);
+        ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
+        when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
+        X x = new X();
+        JsonObject root = new JsonObject();
+        root.addProperty(LifecycleManager.ETSI_CONFIG, new Gson().toJson(additionalParam));
+        x.properties = new Gson().toJson(root);
+        x.vimId = VIM_ID;
+        JsonElement additionalParam = new Gson().toJsonTree(x);
+        instantiationRequest.setAdditionalParam(additionalParam);
+        //when
+        VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
+        waitForJobToFinishInJobManager(finished);
+        assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
+        //verify
+        OPENSTACKV3INFO actualVim = (OPENSTACKV3INFO) actualInstantiationRequest.getValue().getVims().get(0);
+        assertEquals(VIM_ID, actualVim.getId());
+        assertEquals(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, actualVim.getVimInfoType());
+        assertEquals(Boolean.valueOf(parseBoolean(vimInfo.getSslInsecure())), actualVim.getInterfaceInfo().isSkipCertificateVerification());
+        assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint());
+        //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates());
+        assertEquals("vimPassword", actualVim.getAccessInfo().getPassword());
+        assertEquals("regionId", actualVim.getAccessInfo().getRegion());
+        assertEquals("myTenant", actualVim.getAccessInfo().getProject());
+        assertEquals("myDomain", actualVim.getAccessInfo().getDomain());
+        assertEquals("vimUsername", actualVim.getAccessInfo().getUsername());
+        assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification());
+        assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
+    }
+
+    /**
+     * additional params of instantiation may be passed as VNF property
+     */
+    @Test
+    public void testVnfConfigurationBasedOnPackageParametersMissingPropertiesEtsiConfig() throws Exception {
+        VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, false);
+        when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
+        additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
+        when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
+        grantResponse.setVimId(VIM_ID);
+        GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
+        accessInfo.setTenant(TENANT);
+        grantResponse.setAccessInfo(accessInfo);
+        ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
+        when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
+        X x = new X();
+        JsonObject root = new JsonObject();
+        root.addProperty(LifecycleManager.ETSI_CONFIG, new Gson().toJson(additionalParam));
+        x.properties = "{  }";
+        new Gson().toJson(root);
+        x.inputs.put(ONAP_CSAR_ID, new Gson().toJson(additionalParam));
+        x.vimId = VIM_ID;
+        JsonElement additionalParam = new Gson().toJsonTree(x);
+        instantiationRequest.setAdditionalParam(additionalParam);
+        //when
+        VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
+        waitForJobToFinishInJobManager(finished);
+        assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
+        //verify
+        OPENSTACKV3INFO actualVim = (OPENSTACKV3INFO) actualInstantiationRequest.getValue().getVims().get(0);
+        assertEquals(VIM_ID, actualVim.getId());
+        assertEquals(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, actualVim.getVimInfoType());
+        assertEquals(Boolean.valueOf(parseBoolean(vimInfo.getSslInsecure())), actualVim.getInterfaceInfo().isSkipCertificateVerification());
+        assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint());
+        //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates());
+        assertEquals("vimPassword", actualVim.getAccessInfo().getPassword());
+        assertEquals("regionId", actualVim.getAccessInfo().getRegion());
+        assertEquals("myTenant", actualVim.getAccessInfo().getProject());
+        assertEquals("myDomain", actualVim.getAccessInfo().getDomain());
+        assertEquals("vimUsername", actualVim.getAccessInfo().getUsername());
+        assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification());
+        assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck());
+        verify(logger).info("The instantiation input for VNF with {} CSAR id does not have an " + LifecycleManager.ETSI_CONFIG + " section", ONAP_CSAR_ID);
+    }
 }
index 1cbc8ef..6650bd9 100644 (file)
@@ -11,4 +11,8 @@ metadata:
   vnfdVersion: 1.0
 
 topology_template:
+  inputs:
+    etsi_config:
+      type: string
+      description: The ETSI configuration
   node_templates:
index 4944654..5a3871a 100644 (file)
@@ -11,6 +11,10 @@ metadata:
   vnfdVersion: 1.0
 
 topology_template:
+  inputs:
+    etsi_config:
+      type: string
+      description: The ETSI configuration
   node_templates:
     vduNode:
       type: tosca.nodes.nfv.VDU.Compute
index 1e842c8..aa2df37 100644 (file)
@@ -345,7 +345,7 @@ Release AAI
     <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
-      <version>24.0-jre</version>
+      <version>25.0-jre</version>
       <scope>test</scope>
     </dependency>
   </dependencies>