aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java119
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java9
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java20
3 files changed, 78 insertions, 70 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 00ca74b5f4..3f9e52779d 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -714,24 +714,24 @@ public class ToscaResourceInstaller {
}
- protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
- Metadata metadata = nodeTemplate.getMetaData();
+ protected ConfigurationResource getConfigurationResource(IEntityDetails configEntity) {
+ Metadata metadata = configEntity.getMetadata();
ConfigurationResource configResource = new ConfigurationResource();
configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
+ configResource.setToscaNodeType(configEntity.getToscaType());
return configResource;
}
- protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate,
+ protected ConfigurationResourceCustomization getConfigurationResourceCustomization(IEntityDetails configEntity,
ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
Service service) {
- Metadata metadata = nodeTemplate.getMetaData();
+ Metadata metadata = configEntity.getMetadata();
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+ ConfigurationResource configResource = getConfigurationResource(configEntity);
ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
@@ -739,14 +739,12 @@ public class ToscaResourceInstaller {
configCustomizationResource
.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
-
- configCustomizationResource.setFunction(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
- configCustomizationResource.setRole(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
- configCustomizationResource.setType(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
+ configCustomizationResource.setModelInstanceName(configEntity.getName());
+
+ configCustomizationResource.setFunction(getLeafPropertyValue(configEntity, "function"));
+ configCustomizationResource.setRole(getLeafPropertyValue(configEntity, "role"));
+ configCustomizationResource.setType(getLeafPropertyValue(configEntity, "type"));
+
configCustomizationResource.setServiceProxyResourceCustomization(spResourceCustomization);
configCustomizationResource.setConfigurationResource(configResource);
@@ -758,37 +756,39 @@ public class ToscaResourceInstaller {
return configCustomizationResource;
}
-
protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
- List<NodeTemplate> serviceProxyResourceList =
- toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
+ List<IEntityDetails> spEntityList =
+ getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.SERVICE_PROXY),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
- List<NodeTemplate> configurationNodeTemplatesList =
- toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+ List<IEntityDetails> configEntityList =
+ getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CONFIGURATION),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<>();
List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<>();
ServiceProxyResourceCustomization serviceProxy = null;
- if (serviceProxyResourceList != null) {
- for (NodeTemplate spNode : serviceProxyResourceList) {
- serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
+ if (spEntityList != null) {
+ for (IEntityDetails spEntity : spEntityList) {
+ serviceProxy = createServiceProxy(spEntity, service, toscaResourceStruct);
serviceProxyList.add(serviceProxy);
- for (NodeTemplate configNode : configurationNodeTemplatesList) {
+ for (IEntityDetails configEntity : configEntityList) {
- List<RequirementAssignment> requirementsList =
- toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
- for (RequirementAssignment requirement : requirementsList) {
- if (requirement.getNodeTemplateName().equals(spNode.getName())) {
- ConfigurationResourceCustomization configurationResource = createConfiguration(configNode,
+ List<RequirementAssignment> requirements = configEntity.getRequirements();
+
+ for (RequirementAssignment requirement : requirements) {
+
+ if (requirement.getNodeTemplateName().equals(spEntity.getName())) {
+ ConfigurationResourceCustomization configurationResource = createConfiguration(configEntity,
toscaResourceStruct, serviceProxy, service, configurationResourceList);
Optional<ConfigurationResourceCustomization> matchingObject =
configurationResourceList.stream()
- .filter(configurationResourceCustomization -> configNode.getMetaData()
+ .filter(configurationResourceCustomization -> configEntity.getMetadata()
.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)
.equals(configurationResource.getModelCustomizationUUID()))
.filter(configurationResourceCustomization -> configurationResourceCustomization
@@ -1110,7 +1110,7 @@ public class ToscaResourceInstaller {
boolean hasRequirements = false;
for (IEntityDetails vnfcDetails : vnfcMemberNodes) {
- Map<String, RequirementAssignment> requirements = vnfcDetails.getRequirements();
+ List<RequirementAssignment> requirements = vnfcDetails.getRequirements();
if (requirements != null && !requirements.isEmpty()) {
hasRequirements = true;
@@ -1146,15 +1146,14 @@ public class ToscaResourceInstaller {
boolean isAllExists = true;
- Map<String, RequirementAssignment> requirements = memberNode.getRequirements();
+ List<RequirementAssignment> requirements = memberNode.getRequirements();
if (requirements == null || requirements.isEmpty()) {
continue;
}
- for (Map.Entry<String, RequirementAssignment> entry : requirements.entrySet()) {
- RequirementAssignment rqa = entry.getValue();
+ for (RequirementAssignment rqa : requirements) {
String name = rqa.getNodeTemplateName();
for (IEntityDetails node : vnfcMemberNodes) {
if (name.equals(node.getName())) {
@@ -1439,10 +1438,10 @@ public class ToscaResourceInstaller {
return service;
}
- protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service,
+ protected ServiceProxyResourceCustomization createServiceProxy(IEntityDetails spEntity, Service service,
ToscaResourceStructure toscaResourceStructure) {
- Metadata spMetadata = nodeTemplate.getMetaData();
+ Metadata spMetadata = spEntity.getMetadata();
ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
@@ -1457,15 +1456,15 @@ public class ToscaResourceInstaller {
spCustomizationResource
.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+ spCustomizationResource.setModelInstanceName(spEntity.getName());
+ spCustomizationResource.setToscaNodeType(spEntity.getToscaType());
String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
spCustomizationResource.setSourceService(sourceService);
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+ spCustomizationResource.setToscaNodeType(spEntity.getToscaType());
serviceProxyCustomizationSet.add(spCustomizationResource);
@@ -1474,20 +1473,20 @@ public class ToscaResourceInstaller {
return spCustomizationResource;
}
- protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
+ protected ConfigurationResourceCustomization createConfiguration(IEntityDetails configEntity,
ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
Service service, List<ConfigurationResourceCustomization> configurationResourceList) {
ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(
- nodeTemplate, toscaResourceStructure, spResourceCustomization, service);
+ configEntity, toscaResourceStructure, spResourceCustomization, service);
ConfigurationResource configResource = null;
ConfigurationResource existingConfigResource = findExistingConfiguration(service,
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList);
+ configEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID), configurationResourceList);
if (existingConfigResource == null) {
- configResource = getConfigurationResource(nodeTemplate);
+ configResource = getConfigurationResource(configEntity);
} else {
configResource = existingConfigResource;
}
@@ -2192,9 +2191,9 @@ public class ToscaResourceInstaller {
for (IEntityDetails fabricEntity : fabricEntityList) {
- Map<String, RequirementAssignment> requirements = fabricEntity.getRequirements();
+ List<RequirementAssignment> requirements = fabricEntity.getRequirements();
- for (RequirementAssignment requirement : requirements.values()) {
+ for (RequirementAssignment requirement : requirements) {
if (requirement.getNodeTemplateName().equals(cvfcEntity.getName())) {
@@ -2417,8 +2416,7 @@ public class ToscaResourceInstaller {
Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
.filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
- .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
+ .equalsIgnoreCase(vfMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
.findFirst();
if (matchingObject.isPresent()) {
@@ -2575,20 +2573,26 @@ public class ToscaResourceInstaller {
vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
- entityDetails.getCapabilities().get(SCALABLE);
+ List<CapabilityAssignment> capAssignList = entityDetails.getCapabilities();
+ if (capAssignList != null) {
- if (entityDetails.getCapabilities() != null) {
+ for (CapabilityAssignment capAssign : capAssignList) {
- CapabilityAssignment capAssign = entityDetails.getCapabilities().get(SCALABLE);
- if (capAssign != null) {
- vnfResourceCustomization.setMinInstances(Integer
- .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResourceCustomization.setMaxInstances(Integer
- .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
+ if (capAssign != null) {
+ String capabilityName = capAssign.getName();
+
+ if (capabilityName.equalsIgnoreCase(SCALABLE)) {
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(
+ getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(
+ getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+ }
+
+ }
}
if (vnfResourceCustomization.getMinInstances() == null && vnfResourceCustomization.getMaxInstances() == null) {
@@ -2695,12 +2699,11 @@ public class ToscaResourceInstaller {
}
}
- Map<String, CapabilityAssignment> capAssignmentList = arEntity.getCapabilities();
+ List<CapabilityAssignment> capAssignmentList = arEntity.getCapabilities();
if (capAssignmentList != null) {
- for (Map.Entry<String, CapabilityAssignment> entry : capAssignmentList.entrySet()) {
- CapabilityAssignment arCapability = entry.getValue();
+ for (CapabilityAssignment arCapability : capAssignmentList) {
if (arCapability != null) {
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
index 07eca567d5..6908fe4eda 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
@@ -714,6 +714,9 @@ public class ASDCNotificationLogging {
if ("Allotted Resource".equalsIgnoreCase(category)) {
+ buffer.append(System.lineSeparator());
+ buffer.append("Allotted Resource Properties:");
+ buffer.append(System.lineSeparator());
buffer.append("Model Name:");
buffer.append(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
buffer.append(System.lineSeparator());
@@ -739,6 +742,7 @@ public class ASDCNotificationLogging {
buffer.append("Model Description:");
buffer.append(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
buffer.append("Allotted Resource Customization Properties:");
@@ -784,6 +788,9 @@ public class ASDCNotificationLogging {
if ("Allotted Resource".equalsIgnoreCase(category)) {
+ buffer.append(System.lineSeparator());
+ buffer.append("Allotted Resource Properties:");
+ buffer.append(System.lineSeparator());
buffer.append("Model Name:");
buffer.append(testNull(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
buffer.append(System.lineSeparator());
@@ -809,7 +816,7 @@ public class ASDCNotificationLogging {
buffer.append("Model Description:");
buffer.append(pnfAREntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
buffer.append(System.lineSeparator());
-
+ buffer.append(System.lineSeparator());
buffer.append("Allotted Resource Customization Properties:");
buffer.append(System.lineSeparator());
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index ffad137ad7..958519f879 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -622,8 +622,8 @@ public class ToscaResourceInstallerTest extends BaseTest {
}
private void prepareConfigurationResource() {
- doReturn(metadata).when(nodeTemplate).getMetaData();
- doReturn(MockConstants.TEMPLATE_TYPE).when(nodeTemplate).getType();
+ doReturn(metadata).when(entityDetails).getMetadata();
+ doReturn(MockConstants.TEMPLATE_TYPE).when(entityDetails).getToscaType();
doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
doReturn(MockConstants.MODEL_INVARIANT_UUID).when(metadata)
@@ -639,7 +639,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
public void getConfigurationResourceTest() {
prepareConfigurationResource();
- ConfigurationResource configResource = toscaInstaller.getConfigurationResource(nodeTemplate);
+ ConfigurationResource configResource = toscaInstaller.getConfigurationResource(entityDetails);
assertNotNull(configResource);
assertEquals(MockConstants.MODEL_NAME, configResource.getModelName());
@@ -647,7 +647,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
assertEquals(MockConstants.MODEL_UUID, configResource.getModelUUID());
assertEquals(MockConstants.MODEL_VERSION, configResource.getModelVersion());
assertEquals(MockConstants.MODEL_DESCRIPTION, configResource.getDescription());
- assertEquals(MockConstants.TEMPLATE_TYPE, nodeTemplate.getType());
+ assertEquals(MockConstants.TEMPLATE_TYPE, entityDetails.getToscaType());
}
private void prepareConfigurationResourceCustomization() {
@@ -655,13 +655,11 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(metadata)
.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NFFUNCTION);
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NFROLE);
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NFTYPE);
doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(spResourceCustomization).getModelCustomizationUUID();
+ doReturn(null).when(toscaInstaller).getLeafPropertyValue(entityDetails,
+ SdcPropertyNames.PROPERTY_NAME_NFFUNCTION);
+ doReturn(null).when(toscaInstaller).getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE);
+ doReturn(null).when(toscaInstaller).getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE);
}
@@ -670,7 +668,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
prepareConfigurationResourceCustomization();
ConfigurationResourceCustomization configurationResourceCustomization =
- toscaInstaller.getConfigurationResourceCustomization(nodeTemplate, toscaResourceStructure,
+ toscaInstaller.getConfigurationResourceCustomization(entityDetails, toscaResourceStructure,
spResourceCustomization, service);
assertNotNull(configurationResourceCustomization);
assertNotNull(configurationResourceCustomization.getConfigurationResource());