diff options
32 files changed, 300 insertions, 45 deletions
diff --git a/nokiav2/docs/.gitignore b/nokiav2/docs/.gitignore index a96ddfc2..bd19fff5 100644 --- a/nokiav2/docs/.gitignore +++ b/nokiav2/docs/.gitignore @@ -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 index 00000000..8b111b2b --- /dev/null +++ b/nokiav2/docs/sample/vnfm.instantiation.request.json @@ -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 diff --git a/nokiav2/docs/sampleVnfs/simple/cbam.instantiation.request.json b/nokiav2/docs/sampleVnfs/simple/cbam.instantiation.request.json index 5ec6acbc..a85ca0ae 100644 --- a/nokiav2/docs/sampleVnfs/simple/cbam.instantiation.request.json +++ b/nokiav2/docs/sampleVnfs/simple/cbam.instantiation.request.json @@ -41,20 +41,20 @@ "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/sdc.json b/nokiav2/docs/sampleVnfs/simple/sdc.json new file mode 100644 index 00000000..e6da9e17 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple/sdc.json @@ -0,0 +1 @@ +{ "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" } ] } diff --git a/nokiav2/docs/sampleVnfs/simple/simple.csar b/nokiav2/docs/sampleVnfs/simple/simple.csar Binary files differindex da3637fe..fc03b56a 100644 --- a/nokiav2/docs/sampleVnfs/simple/simple.csar +++ b/nokiav2/docs/sampleVnfs/simple/simple.csar 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 index 00000000..811f13a0 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple/vfc.ns.instantiation.request.direct.json @@ -0,0 +1,6 @@ +{ + "nsInstanceId": "23fd3ae5-c261-4662-9fcd-35107d33954f", + "additionalParamForNs": { + "location": "Nokia_RegionOne" + } +}
\ No newline at end of file diff --git a/nokiav2/docs/sampleVnfs/simpleDual/cbam.instantiation.request.json b/nokiav2/docs/sampleVnfs/simpleDual/cbam.instantiation.request.json index 5ec6acbc..16fc4d14 100644 --- a/nokiav2/docs/sampleVnfs/simpleDual/cbam.instantiation.request.json +++ b/nokiav2/docs/sampleVnfs/simpleDual/cbam.instantiation.request.json @@ -41,13 +41,13 @@ "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 diff --git a/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar b/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar Binary files differindex 7b0b57f0..3a43b788 100644 --- a/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar +++ b/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar 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 index 00000000..452b10bb --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simpleDual/vfc.ns.instantiation.request.direct.json @@ -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 index 00000000..0e0dcd23 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/cbam.instantiation.request.json @@ -0,0 +1,3 @@ +{ + +}
\ No newline at end of file diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/sdc.json b/nokiav2/docs/sampleVnfs/simple_cmcc/sdc.json new file mode 100644 index 00000000..16563884 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/sdc.json @@ -0,0 +1 @@ +{ "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/simple.csar b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar Binary files differnew file mode 100644 index 00000000..da3637fe --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar 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 index 00000000..d6e9d2dc --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.create.request.json @@ -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 index 00000000..49c79212 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.heal.request.json @@ -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 index 00000000..41820092 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.direct.json @@ -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 index 00000000..01f37938 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.ns.instantiation.request.json @@ -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 index 00000000..3140f4a4 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/vfc.vnf.scale.request.json @@ -0,0 +1,8 @@ +{ + "scaleVnfData" : + { + "type" : "SCALE_OUT", + "aspectId" : "simpleAspect", + "numberOfSteps" : "1" + } +}
\ No newline at end of file diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java index 17060d67..123f263d 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java @@ -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); 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 d0df8a80..164d3a23 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 @@ -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(); } 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 6a20bc20..406f0033 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 @@ -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"; } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java index b4e59151..116420d6 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java @@ -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); } 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 b826931e..0adba680 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 @@ -67,6 +67,7 @@ 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"; private static Logger logger = getLogger(LifecycleManager.class); private final CatalogManager catalogManager; private final IGrantManager grantManager; @@ -291,9 +292,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 etsi_config = properties.get(ETSI_CONFIG); + return new Gson().fromJson(etsi_config.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); diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java index d2378853..1bda9a3c 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForVfc.java @@ -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; 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 9b497343..4829d296 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 @@ -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,19 @@ 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) { + return toleratedFailure(); } } @@ -226,15 +231,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(); + } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java index d1e2dea1..b082dbd4 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestSelfRegistrationManager.java @@ -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(); 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 912a2209..fd5f112e 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 @@ -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 diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java index 5ade389d..b4783b41 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestGenericVnfManager.java @@ -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 index 00000000..58afb9bd --- /dev/null +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestConstants.java @@ -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 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 026e65d0..7760011d 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 @@ -264,6 +264,7 @@ public class TestLifecycleManager extends TestBase { 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); } /** @@ -1192,8 +1193,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,6 +1666,8 @@ 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) { @@ -1673,6 +1676,23 @@ public class TestLifecycleManager extends TestBase { 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); + 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) { additionalParam.setInstantiationLevel("level1"); switch (cloudType) { case OPENSTACK_V2_INFO: @@ -1713,12 +1733,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 +1745,6 @@ 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; } /** @@ -1748,4 +1755,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); + 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); + 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); + } } 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 bfb30abd..d0657852 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,6 +23,7 @@ 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/resources/unittests/packageconverter/empty.vnfd.onap.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.yaml index 1cbc8ef7..6650bd91 100644 --- a/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.yaml +++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/empty.vnfd.onap.yaml @@ -11,4 +11,8 @@ metadata: vnfdVersion: 1.0 topology_template: + inputs: + etsi_config: + type: string + description: The ETSI configuration node_templates: diff --git a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.yaml b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.yaml index 49446544..5a3871af 100644 --- a/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.yaml +++ b/nokiav2/driver/src/test/resources/unittests/packageconverter/nodes.vnfd.onap.yaml @@ -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 |