diff options
10 files changed, 200 insertions, 55 deletions
diff --git a/nokiav2/docs/sampleVnfs/simple/etsi_config.json b/nokiav2/docs/sampleVnfs/simple/etsi_config.json new file mode 100644 index 00000000..a0cff014 --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple/etsi_config.json @@ -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 diff --git a/nokiav2/docs/sampleVnfs/simple/sdc.json b/nokiav2/docs/sampleVnfs/simple/sdc.json deleted file mode 100644 index e6da9e17..00000000 --- a/nokiav2/docs/sampleVnfs/simple/sdc.json +++ /dev/null @@ -1 +0,0 @@ -{ "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 fc03b56a..a3726c19 100644 --- a/nokiav2/docs/sampleVnfs/simple/simple.csar +++ b/nokiav2/docs/sampleVnfs/simple/simple.csar diff --git a/nokiav2/docs/sampleVnfs/simple_cmcc/etsi_config.json b/nokiav2/docs/sampleVnfs/simple_cmcc/etsi_config.json new file mode 100644 index 00000000..ef3bce5c --- /dev/null +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/etsi_config.json @@ -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/sdc.json b/nokiav2/docs/sampleVnfs/simple_cmcc/sdc.json deleted file mode 100644 index 16563884..00000000 --- a/nokiav2/docs/sampleVnfs/simple_cmcc/sdc.json +++ /dev/null @@ -1 +0,0 @@ -{ "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 differindex da3637fe..48a38b8e 100644 --- a/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar +++ b/nokiav2/docs/sampleVnfs/simple_cmcc/simple.csar diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java index c0b5c5b8..5895108f 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/AdditionalParameters.java @@ -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 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 0adba680..5d65050c 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 @@ -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; @@ -68,6 +71,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"; + public static final String PROPERTIES = "properties"; private static Logger logger = getLogger(LifecycleManager.class); private final CatalogManager catalogManager; private final IGrantManager grantManager; @@ -215,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()); @@ -293,11 +298,11 @@ public class LifecycleManager { private AdditionalParameters convertInstantiationAdditionalParams(String csarId, Object additionalParams) { JsonObject root = new Gson().toJsonTree(additionalParams).getAsJsonObject(); - if(root.has("properties")){ - JsonObject properties = new JsonParser().parse(root.get("properties").getAsString()).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); + 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); @@ -317,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(); } @@ -345,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); } } 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 4829d296..c4cd4342 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 @@ -223,6 +223,7 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif throw handledFailuire; } catch (Exception e) { + logger.warn("Unable to build affected connection points", e); return toleratedFailure(); } } 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 7760011d..d91c8477 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 @@ -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,12 +252,32 @@ 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()); @@ -273,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 @@ -295,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); @@ -331,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); @@ -358,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); @@ -396,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); @@ -489,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); @@ -528,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); @@ -565,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); @@ -602,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); @@ -627,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); @@ -661,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); @@ -699,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); @@ -733,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); @@ -759,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); @@ -786,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); @@ -813,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); @@ -854,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); @@ -875,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)); @@ -888,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); } } @@ -898,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); @@ -1185,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 @@ -1670,7 +1690,7 @@ public class TestLifecycleManager extends TestBase { 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); @@ -1682,7 +1702,7 @@ public class TestLifecycleManager extends TestBase { externalVirtualLink.setResourceSubnetId("notUsedSubnetId"); instantiationRequest.setExtVirtualLink(new ArrayList<>()); instantiationRequest.getExtVirtualLink().add(externalVirtualLink); - buildAdditionalParams(cloudType); + buildAdditionalParams(cloudType, addExtension); String params = new Gson().toJson(additionalParam); X x = new X(); x.inputs.put(ONAP_CSAR_ID, params); @@ -1692,7 +1712,7 @@ public class TestLifecycleManager extends TestBase { return instantiationRequest; } - private void buildAdditionalParams(VimInfo.VimInfoTypeEnum cloudType) { + private void buildAdditionalParams(VimInfo.VimInfoTypeEnum cloudType, boolean addExtensions) { additionalParam.setInstantiationLevel("level1"); switch (cloudType) { case OPENSTACK_V2_INFO: @@ -1745,6 +1765,22 @@ public class TestLifecycleManager extends TestBase { image.setVnfdSoftwareImageId("imageId"); additionalParam.getSoftwareImages().add(image); additionalParam.setAdditionalParams(new JsonParser().parse("{ \"a\" : \"b\" }")); + 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); + } } /** @@ -1761,7 +1797,7 @@ public class TestLifecycleManager extends TestBase { */ @Test public void testVnfConfigurationBasedOnPackageParameters() 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); @@ -1803,7 +1839,7 @@ public class TestLifecycleManager extends TestBase { */ @Test public void testVnfConfigurationBasedOnPackageParametersMissingPropertiesEtsiConfig() 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); |