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;
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;
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;
@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());
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);
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();
}
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);
}
}
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;
@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);
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());
@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
*/
@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);
*/
@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);
*/
@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);
@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);
*/
@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);
*/
@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);
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);
*/
@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);
*/
@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);
*/
@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);
*/
@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);
*/
@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);
*/
@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);
*/
@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);
*/
@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);
@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);
@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));
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);
}
}
*/
@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);
@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
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);
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);
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:
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);
+ }
}
/**
*/
@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);
*/
@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);