summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java86
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java39
2 files changed, 51 insertions, 74 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index d39da5ee37..a808393e05 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1584,9 +1584,10 @@ public class BBInputSetup implements JavaDelegate {
Vnfs vnfs = null;
VfModules vfModules = null;
Networks networks = null;
+
CloudConfiguration cloudConfiguration = requestDetails.getCloudConfiguration();
- CloudRegion cloudRegion = getCloudRegionFromMacroRequest(cloudConfiguration, resources);
- gBB.setCloudRegion(cloudRegion);
+ CloudRegion cloudRegion = setCloudConfiguration(gBB, cloudConfiguration);
+
BBInputSetupParameter parameter =
new BBInputSetupParameter.Builder().setRequestId(executeBB.getRequestId()).setService(service)
.setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).build();
@@ -1599,6 +1600,11 @@ public class BBInputSetup implements JavaDelegate {
vnfs = findVnfsByKey(key, resources);
}
+ // Vnf level cloud configuration takes precedence over service level cloud configuration.
+ if (vnfs.getCloudConfiguration() != null) {
+ setCloudConfiguration(gBB, vnfs.getCloudConfiguration());
+ }
+
String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
// This stores the vnf id in request db to be retrieved later when
// working on a vf module or volume group
@@ -1635,6 +1641,21 @@ public class BBInputSetup implements JavaDelegate {
vfModules = getVfModulesByKey(key, resources);
}
+ String vfModulesName = vfModules.getInstanceName();
+ String vfModulesModelCustId = vfModules.getModelInfo().getModelCustomizationId();
+ // Get the Vnf associated with vfModule
+ Optional<org.onap.so.serviceinstancebeans.Vnfs> parentVnf = resources.getVnfs().stream()
+ .filter(aVnf -> aVnf.getCloudConfiguration() != null)
+ .filter(aVnf -> aVnf.getVfModules().stream()
+ .anyMatch(aVfModules -> aVfModules.getInstanceName().equals(vfModulesName) && aVfModules
+ .getModelInfo().getModelCustomizationId().equals(vfModulesModelCustId)))
+ .findAny();
+
+ // Get the cloud configuration from this Vnf
+ if (parentVnf.isPresent()) {
+ cloudRegion = setCloudConfiguration(gBB, parentVnf.get().getCloudConfiguration());
+ }
+
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, getVnfId(executeBB, lookupKeyMap));
parameter.setModelInfo(vfModules.getModelInfo());
@@ -1665,6 +1686,16 @@ public class BBInputSetup implements JavaDelegate {
networks = findNetworksByKey(key, resources);
String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
if (networks != null) {
+ // If service level cloud configuration is not provided then get it from networks.
+ if (cloudConfiguration == null) {
+ Optional<org.onap.so.serviceinstancebeans.Networks> netWithCloudConfig = resources.getNetworks()
+ .stream().filter(aNetwork -> aNetwork.getCloudConfiguration() != null).findAny();
+ if (netWithCloudConfig.isPresent()) {
+ setCloudConfiguration(gBB, netWithCloudConfig.get().getCloudConfiguration());
+ } else {
+ logger.debug("Could not find any cloud configuration for this request.");
+ }
+ }
parameter.setInstanceName(networks.getInstanceName());
parameter.setModelInfo(networks.getModelInfo());
parameter.setInstanceParams(networks.getInstanceParams());
@@ -1690,6 +1721,24 @@ public class BBInputSetup implements JavaDelegate {
return gBB;
}
+ /**
+ * setCloudConfiguration - set cloud info on a building block.
+ *
+ * @param gBB
+ * @param cloudConfiguration
+ * @return CloudRegion
+ * @throws Exception
+ */
+ private CloudRegion setCloudConfiguration(GeneralBuildingBlock gBB, CloudConfiguration cloudConfiguration)
+ throws Exception {
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
+ Tenant tenant = getTenant(cloudConfiguration, aaiCloudRegion);
+ gBB.setTenant(tenant);
+ CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
+ gBB.setCloudRegion(cloudRegion);
+ return cloudRegion;
+ }
+
protected Networks findNetworksByKey(String key, Resources resources) {
for (Networks networks : resources.getNetworks()) {
if (networks.getModelInfo().getModelCustomizationId().equalsIgnoreCase(key)) {
@@ -1740,39 +1789,6 @@ public class BBInputSetup implements JavaDelegate {
throw new ResourceNotFoundException("Could not find vnf with key: " + key + " in userparams");
}
- protected CloudRegion getCloudRegionFromMacroRequest(CloudConfiguration cloudConfiguration, Resources resources) {
- if (cloudConfiguration == null) {
- for (Vnfs vnfs : resources.getVnfs()) {
- if (cloudConfiguration == null) {
- cloudConfiguration = vnfs.getCloudConfiguration();
- } else {
- break;
- }
- for (VfModules vfModules : vnfs.getVfModules()) {
- if (cloudConfiguration == null) {
- cloudConfiguration = vfModules.getCloudConfiguration();
- } else {
- break;
- }
- }
- }
- for (Networks networks : resources.getNetworks()) {
- if (cloudConfiguration == null) {
- cloudConfiguration = networks.getCloudConfiguration();
- } else {
- break;
- }
- }
- }
- if (cloudConfiguration != null) {
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
- return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
- } else {
- logger.debug("Could not find any cloud configuration for this request.");
- return null;
- }
- }
-
protected String getVnfId(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap) {
String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
if (vnfId == null) {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index b561055468..d405cff8bb 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -2282,45 +2282,6 @@ public class BBInputSetupTest {
}
@Test
- public void testgetGBBMacroCloudConfiguration() throws Exception {
- org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
- CloudConfiguration cloudConfig = null;
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion();
- aaiCloudRegion.setCloudOwner("test-owner-name");
- Resources resources = serviceMacro.getResources();
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class));
- CloudRegion expected = new CloudRegion();
- expected.setLcpCloudRegionId("mdt1");
- expected.setCloudOwner("test-owner-name");
- expected.setTenantId("88a6ca3ee0394ade9403f075db23167e");
-
- CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroVnfs.json"),
- org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNetworks.json"),
- org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNoCloudConfig.json"),
- org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertNull(actual);
- }
-
- @Test
public void testgetGBBMacroWithEmptyUserParams() throws Exception {
String resourceId = "123";
String vnfType = "vnfType";