aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java7
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java26
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java7
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java770
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java3
5 files changed, 450 insertions, 363 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java
index c37eccf594..06887f1253 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/ActivitySpecsActions.java
@@ -29,7 +29,8 @@ import org.onap.so.asdc.activity.beans.ActivitySpec;
import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
import org.onap.so.client.HttpClient;
import org.onap.so.client.HttpClientFactory;
-import org.onap.so.utils.TargetEntity;
+import org.onap.so.logger.LoggingAnchor;
+import org.onap.logging.filter.base.ONAPComponents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -62,7 +63,7 @@ public class ActivitySpecsActions {
String urlString = UriBuilder.fromUri(hostname).path(ACTIVITY_SPEC_URI).build().toString();
URL url = new URL(urlString);
- HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC);
+ HttpClient httpClient = httpClientFactory.newJsonClient(url, ONAPComponents.SDC);
httpClient.addAdditionalHeader("Content-Type", ContentType.APPLICATION_JSON.toString());
Response response = httpClient.post(payload);
@@ -104,7 +105,7 @@ public class ActivitySpecsActions {
String urlString = UriBuilder.fromUri(hostname).path(path).build().toString();
URL url = new URL(urlString);
- HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC);
+ HttpClient httpClient = httpClientFactory.newJsonClient(url, ONAPComponents.SDC);
httpClient.addAdditionalHeader("Content-Type", ContentType.APPLICATION_JSON.toString());
Response response = httpClient.put(CERTIFY_ACTIVITY_PAYLOAD);
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
index 0fc94c8bd6..7f1c1968c1 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
@@ -20,6 +20,8 @@
package org.onap.so.asdc.activity;
+import java.net.HttpURLConnection;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.onap.so.logger.LoggingAnchor;
@@ -27,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import org.apache.http.HttpStatus;
import org.onap.so.asdc.activity.beans.ActivitySpec;
import org.onap.so.asdc.activity.beans.Input;
import org.onap.so.asdc.activity.beans.Output;
@@ -59,6 +62,11 @@ public class DeployActivitySpecs {
String hostname = env.getProperty(SDC_ENDPOINT);
logger.debug("{} {}", "SDC ActivitySpec endpoint: ", hostname);
if (hostname == null || hostname.isEmpty()) {
+ logger.warn("The hostname for SDC activities deployment is not configured in SO");
+ return;
+ }
+ if (!checkHttpOk(hostname)) {
+ logger.warn("The sdc end point is not alive");
return;
}
List<org.onap.so.db.catalog.beans.ActivitySpec> activitySpecsFromCatalog = activitySpecRepository.findAll();
@@ -135,4 +143,22 @@ public class DeployActivitySpecs {
activitySpec.setOutputs(outputs);
return;
}
+
+ public boolean checkHttpOk(String host) {
+ URL url = null;
+ boolean isOk = false;
+
+ int responseCode = 0;
+ try {
+ url = new URL(host);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ responseCode = connection.getResponseCode();
+ } catch (Exception e) {
+ logger.warn("Exception on connecting to SDC WFD endpoint: " + e.getMessage());
+ }
+ if (responseCode == HttpStatus.SC_OK) {
+ isOk = true;
+ }
+ return isOk;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index 9ffc38d34b..0080ed543c 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -741,8 +741,7 @@ public class ASDCController {
logger.info("Processing Resource Type: {}, Model UUID: {}", resourceType, resource.getResourceUUID());
- if ("VF".equals(resourceType) && resource.getArtifacts() != null
- && !resource.getArtifacts().isEmpty()) {
+ if ("VF".equals(resourceType)) {
resourceStructure = new VfResourceStructure(iNotif, resource);
} else if ("PNF".equals(resourceType)) {
resourceStructure = new PnfResourceStructure(iNotif, resource);
@@ -760,8 +759,8 @@ public class ASDCController {
logger.debug("Processing Resource Type: " + resourceType + " and Model UUID: "
+ resourceStructure.getResourceInstance().getResourceUUID());
- if ("VF".equals(resourceType) && resource.getArtifacts() != null
- && !resource.getArtifacts().isEmpty()) {
+
+ if ("VF".equals(resourceType)) {
hasVFResource = true;
for (IArtifactInfo artifact : resource.getArtifacts()) {
IDistributionClientDownloadResult resultArtifact =
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 bcb81ba87c..e8e068a71a 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
@@ -26,6 +26,7 @@ package org.onap.so.asdc.installer.heat;
import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -434,17 +435,26 @@ public class ToscaResourceInstaller {
Service service = toscaResourceStruct.getCatalogService();
List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
- Metadata metadata = nodeTemplate.getMetaData();
- String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
- vfCustomizationCategory);
+ List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct,
+ EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
+
+ List<IEntityDetails> arEntityDetails = new ArrayList<IEntityDetails>();
+
+ for (IEntityDetails vfEntityDetails : vfEntityList) {
+
+ Metadata metadata = vfEntityDetails.getMetadata();
+ String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+
+ if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) {
+ arEntityDetails.add(vfEntityDetails);
+ }
+
+ processVfModules(vfEntityDetails, vfNodeTemplatesList.get(0), toscaResourceStruct, vfResourceStructure,
+ service, metadata);
}
processResourceSequence(toscaResourceStruct, service);
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
- processAllottedResources(toscaResourceStruct, service, allottedResourceList);
+ processAllottedResources(arEntityDetails, toscaResourceStruct, service);
processNetworks(toscaResourceStruct, service);
// process Network Collections
processNetworkCollections(toscaResourceStruct, service);
@@ -571,7 +581,8 @@ public class ToscaResourceInstaller {
String outInput;
String defaultValue = null;
if (value instanceof Map) {
- outInput = ((LinkedHashMap) value).values().toArray()[0].toString();
+ Collection values = ((LinkedHashMap) value).values();
+ outInput = (values.size() > 0) ? values.toArray()[0].toString() : "";
} else if (value instanceof GetInput) {
String inputName = ((GetInput) value).getInputName();
Optional<Input> inputOptional =
@@ -631,7 +642,8 @@ public class ToscaResourceInstaller {
protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
throws ArtifactInstallerException {
- List<IEntityDetails> vlEntityList = getEntityDetails(toscaResourceStruct, SdcTypes.VL, SdcTypes.SERVICE, false);
+ List<IEntityDetails> vlEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.VL),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
if (vlEntityList != null) {
for (IEntityDetails vlEntity : vlEntityList) {
@@ -647,7 +659,10 @@ public class ToscaResourceInstaller {
NetworkResourceCustomization networkCustomization = createNetwork(vlEntity, toscaResourceStruct,
heatTemplate, tempNetworkLookUp.getAicVersionMax(),
tempNetworkLookUp.getAicVersionMin(), service);
- service.getNetworkCustomizations().add(networkCustomization);
+ // only insert unique entries
+ if (!service.getNetworkCustomizations().contains(networkCustomization)) {
+ service.getNetworkCustomizations().add(networkCustomization);
+ }
} else {
throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: "
+ tempNetworkLookUp.getHeatTemplateArtifactUuid());
@@ -655,6 +670,8 @@ public class ToscaResourceInstaller {
} else {
NetworkResourceCustomization networkCustomization =
createNetwork(vlEntity, toscaResourceStruct, null, null, null, service);
+ networkCustomization.setResourceInput(
+ getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID()));
service.getNetworkCustomizations().add(networkCustomization);
logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ networkResourceModelName);
@@ -664,12 +681,32 @@ public class ToscaResourceInstaller {
}
}
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
- List<NodeTemplate> allottedResourceList) {
- if (allottedResourceList != null) {
- for (NodeTemplate allottedNode : allottedResourceList) {
- service.getAllottedCustomizations()
- .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
+ protected void processAllottedResources(List<IEntityDetails> arEntityDetails,
+ ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException {
+
+ List<IEntityDetails> pnfAREntityList = getEntityDetails(toscaResourceStruct,
+ EntityQuery.newBuilder(SdcTypes.PNF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
+
+ for (IEntityDetails pnfEntity : pnfAREntityList) {
+
+ Metadata metadata = pnfEntity.getMetadata();
+ String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) {
+ arEntityDetails.add(pnfEntity);
+ }
+
+ }
+
+ if (arEntityDetails != null) {
+ for (IEntityDetails arEntity : arEntityDetails) {
+ AllottedResourceCustomization allottedResource =
+ createAllottedResource(arEntity, toscaResourceStruct, service);
+ String resourceInput =
+ getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID());
+ if (!"{}".equals(resourceInput)) {
+ allottedResource.setResourceInput(resourceInput);
+ }
+ service.getAllottedCustomizations().add(allottedResource);
}
}
}
@@ -804,13 +841,13 @@ public class ToscaResourceInstaller {
protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
- List<NodeTemplate> networkCollectionList =
- toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
+ List<IEntityDetails> crEntityList = getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder(SdcTypes.CR),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
- if (networkCollectionList != null) {
- for (NodeTemplate crNode : networkCollectionList) {
+ if (crEntityList != null) {
+ for (IEntityDetails ncEntity : crEntityList) {
- createNetworkCollection(crNode, toscaResourceStruct, service);
+ createNetworkCollection(ncEntity, toscaResourceStruct, service);
collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
List<NetworkInstanceGroup> networkInstanceGroupList =
@@ -954,34 +991,37 @@ public class ToscaResourceInstaller {
return String.valueOf(value);
}
- protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
- Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory)
- throws Exception {
+ protected void processVfModules(IEntityDetails vfEntityDetails, NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, Service service,
+ Metadata metadata) throws Exception {
+
+ String vfCustomizationCategory =
+ vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
logger.debug("VF Category is : " + vfCustomizationCategory);
- if (vfResourceStructure.getVfModuleStructure() != null
- && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
+ String vfCustomizationUUID =
+ vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata,
- SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
- // comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
- + vfCustomizationUUID);
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
+ // comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+ + vfCustomizationUUID);
- if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
- + " matches vfNotificationResource CustomizationUUID");
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+ VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
+ if (vfResourceStructure.getVfModuleStructure() != null
+ && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>();
Set<VnfcCustomization> existingVnfcSet = new HashSet<>();
List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom = new ArrayList<>();
@@ -989,14 +1029,19 @@ public class ToscaResourceInstaller {
for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
- List<org.onap.sdc.toscaparser.api.Group> vfGroups =
- toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
+
+ List<IEntityDetails> vfModuleEntityList =
+ getEntityDetails(toscaResourceStruct,
+ EntityQuery.newBuilder("org.openecomp.groups.VfModule"), TopologyTemplateQuery
+ .newBuilder(SdcTypes.SERVICE).customizationUUID(vfCustomizationUUID),
+ false);
+
IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : "
+ vfMetadata.getVfModuleModelCustomizationUUID());
- Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+ Optional<IEntityDetails> matchingObject = vfModuleEntityList.stream()
.peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID "
+ group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
.filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID")
@@ -1004,7 +1049,7 @@ public class ToscaResourceInstaller {
.findFirst();
if (matchingObject.isPresent()) {
VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(),
- nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource,
+ toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource, service,
existingCvnfcSet, existingVnfcSet, existingCvnfcConfigurationCustom);
vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
} else
@@ -1013,34 +1058,33 @@ public class ToscaResourceInstaller {
+ vfMetadata.getVfModuleModelCustomizationUUID());
}
+ }
- // Check for VNFC Instance Group info and add it if there is
- List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct,
- "org.openecomp.groups.VfcInstanceGroup",
- TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
+ // Check for VNFC Instance Group info and add it if there is
+ List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct,
+ EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"),
+ TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
- for (IEntityDetails groupEntity : vfcEntityList) {
- VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
- createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct);
- vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
- }
+ for (IEntityDetails groupEntity : vfcEntityList) {
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
+ createVNFCInstanceGroup(groupEntity, nodeTemplate, vnfResource, toscaResourceStruct);
+ vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
+ }
- List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
- if (!CollectionUtils.isEmpty(seqResult)) {
- String resultStr = seqResult.stream().collect(Collectors.joining(","));
- vnfResource.setVnfcInstanceGroupOrder(resultStr);
- logger.debug(
- "vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr);
- }
- // add this vnfResource with existing vnfResource for this service
- addVnfCustomization(service, vnfResource);
- } else {
- logger.debug("Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
- + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, vfcEntityList);
+ if (!CollectionUtils.isEmpty(seqResult)) {
+ String resultStr = seqResult.stream().collect(Collectors.joining(","));
+ vnfResource.setVnfcInstanceGroupOrder(resultStr);
+ logger.debug("vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr);
}
+ // add this vnfResource with existing vnfResource for this service
+ addVnfCustomization(service, vnfResource);
+ } else {
+ logger.debug("Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ + "Tosca VF Customization UUID: " + vfCustomizationUUID);
}
}
@@ -1349,7 +1393,14 @@ public class ToscaResourceInstaller {
Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
- Service service = new Service();
+ List<Service> services =
+ serviceRepo.findByModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ Service service;
+ if (!services.isEmpty() && services.size() > 0) {
+ service = services.get(0);
+ } else {
+ service = new Service();
+ }
if (serviceMetadata != null) {
@@ -1461,13 +1512,20 @@ public class ToscaResourceInstaller {
}
protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
- ToscaCsar toscaCsar = new ToscaCsar();
+ Optional<ToscaCsar> toscaCsarOpt =
+ toscaCsarRepo.findById(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+ ToscaCsar toscaCsar;
+ if (!toscaCsarOpt.isPresent()) {
+ toscaCsar = new ToscaCsar();
+ toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+ } else {
+ toscaCsar = toscaCsarOpt.get();
+ }
if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
} else {
toscaCsar.setArtifactChecksum(MANUAL_RECORD);
}
- toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
@@ -1620,7 +1678,7 @@ public class ToscaResourceInstaller {
return networkResource;
}
- protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
+ protected CollectionNetworkResourceCustomization createNetworkCollection(IEntityDetails cnrEntity,
ToscaResourceStructure toscaResourceStructure, Service service) {
CollectionNetworkResourceCustomization collectionNetworkResourceCustomization =
@@ -1629,33 +1687,26 @@ public class ToscaResourceInstaller {
// **** Build Object to populate Collection_Resource table
CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setModelName(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
collectionResource
- .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- collectionResource.setModelInvariantUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- collectionResource
- .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- collectionResource
- .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- collectionResource
- .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- collectionResource.setToscaNodeType(networkNodeTemplate.getType());
+ .setModelInvariantUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ collectionResource.setModelUUID(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ collectionResource.setModelVersion(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ collectionResource.setDescription(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ collectionResource.setToscaNodeType(cnrEntity.getToscaType());
toscaResourceStructure.setCatalogCollectionResource(collectionResource);
// **** Build object to populate Collection_Resource_Customization table
NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
- ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_function"));
- ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_role"));
- ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_type"));
+ ncfc.setFunction(getLeafPropertyValue(cnrEntity, "cr_function"));
+ ncfc.setRole(getLeafPropertyValue(cnrEntity, "cr_role"));
+ ncfc.setType(getLeafPropertyValue(cnrEntity, "cr_type"));
- ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ ncfc.setModelInstanceName(cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
ncfc.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
@@ -1666,25 +1717,28 @@ public class ToscaResourceInstaller {
toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
// *** Build object to populate the Instance_Group table
- List<Group> groupList =
- toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
- networkNodeTemplate, "org.openecomp.groups.NetworkCollection");
+ List<IEntityDetails> ncEntityList =
+ getEntityDetails(toscaResourceStructure,
+ EntityQuery.newBuilder("org.openecomp.groups.NetworkCollection"),
+ TopologyTemplateQuery.newBuilder(SdcTypes.CR).customizationUUID(
+ cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)),
+ false);
List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList =
new ArrayList<>();
- for (Group group : groupList) {
+ for (IEntityDetails ncGroupEntity : ncEntityList) {
NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
- Metadata instanceMetadata = group.getMetadata();
+ Metadata instanceMetadata = ncGroupEntity.getMetadata();
networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
networkInstanceGroup
.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- networkInstanceGroup.setToscaNodeType(group.getType());
+ networkInstanceGroup.setToscaNodeType(ncGroupEntity.getToscaType());
networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
// Role
networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
@@ -1698,27 +1752,26 @@ public class ToscaResourceInstaller {
crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
crInstanceGroupCustomization.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
// Loop through the template policy to find the subinterface_network_quantity property name. Then extract
// the value for it.
- List<Policy> policyList =
- toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(
- networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
+ List<IEntityDetails> policyEntityList = getEntityDetails(toscaResourceStructure,
+ EntityQuery.newBuilder("org.openecomp.policies.scaling.Fixed"),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), true);
- if (policyList != null) {
- for (Policy policy : policyList) {
- for (String policyNetworkCollection : policy.getTargets()) {
+ if (policyEntityList != null) {
+ for (IEntityDetails policyEntity : policyEntityList) {
+ for (String policyNetworkCollection : policyEntity.getTargets()) {
- if (policyNetworkCollection.equalsIgnoreCase(group.getName())) {
+ if (policyNetworkCollection.equalsIgnoreCase(ncGroupEntity.getName())) {
- Map<String, Object> propMap = policy.getPolicyProperties();
+ Map<String, Property> propMap = policyEntity.getProperties();
if (propMap.get("quantity") != null) {
- String quantity = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- getPropertyInput(propMap.get("quantity").toString()));
+ String quantity = getLeafPropertyValue(cnrEntity,
+ getPropertyInput(propMap.get("quantity").toString()));
if (quantity != null) {
crInstanceGroupCustomization
@@ -1733,13 +1786,12 @@ public class ToscaResourceInstaller {
}
crInstanceGroupCustomization.setDescription(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_description"));
- crInstanceGroupCustomization.setFunction(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_function"));
+ getLeafPropertyValue(cnrEntity, instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_description"));
+
+ crInstanceGroupCustomization.setFunction(getLeafPropertyValue(cnrEntity,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME) + "_network_collection_function"));
+
crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
@@ -1751,18 +1803,21 @@ public class ToscaResourceInstaller {
toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
- List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
+ List<IEntityDetails> networkEntityList =
+ getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VL),
+ TopologyTemplateQuery.newBuilder(SdcTypes.CR).customizationUUID(
+ cnrEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)),
+ false);
List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
// *****Build object to populate the NetworkResource table
NetworkResource networkResource = new NetworkResource();
- for (NodeTemplate vlNodeTemplate : vlNodeList) {
+ for (IEntityDetails networkEntity : networkEntityList) {
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+ String providerNetwork = getLeafPropertyValue(networkEntity,
+ SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
if ("true".equalsIgnoreCase(providerNetwork)) {
networkResource.setNeutronNetworkType(PROVIDER);
@@ -1770,22 +1825,20 @@ public class ToscaResourceInstaller {
networkResource.setNeutronNetworkType(BASIC);
}
- networkResource
- .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ networkResource.setModelName(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
networkResource.setModelInvariantUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkResource
- .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkResource.setModelUUID(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
networkResource
- .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ .setModelVersion(networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
networkResource.setAicVersionMax(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
TempNetworkHeatTemplateLookup tempNetworkLookUp =
tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
if (tempNetworkLookUp != null) {
@@ -1797,29 +1850,28 @@ public class ToscaResourceInstaller {
}
- networkResource.setToscaNodeType(vlNodeTemplate.getType());
+ networkResource.setToscaNodeType(networkEntity.getToscaType());
networkResource.setDescription(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
networkResource.setOrchestrationMode(HEAT);
// Build object to populate the
// Collection_Network_Resource_Customization table
- for (NodeTemplate memberNode : group.getMemberNodes()) {
- collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
+ for (IEntityDetails networkMemberEntity : ncGroupEntity.getMemberNodes()) {
+ collectionNetworkResourceCustomization.setModelInstanceName(networkMemberEntity.getName());
}
collectionNetworkResourceCustomization.setModelCustomizationUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ networkEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
collectionNetworkResourceCustomization.setNetworkTechnology(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
- collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ collectionNetworkResourceCustomization.setNetworkType(
+ getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ collectionNetworkResourceCustomization.setNetworkRole(
+ getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ collectionNetworkResourceCustomization.setNetworkScope(
+ getLeafPropertyValue(networkEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
collectionNetworkResourceCustomization.setNetworkResource(networkResource);
collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
@@ -1841,10 +1893,11 @@ public class ToscaResourceInstaller {
InstanceGroup existingInstanceGroup =
instanceGroupRepo.findByModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+ VFCInstanceGroup vfcInstanceGroup;
if (existingInstanceGroup == null) {
// Populate InstanceGroup
+ vfcInstanceGroup = new VFCInstanceGroup();
vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
vfcInstanceGroup
.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
@@ -1891,9 +1944,10 @@ public class ToscaResourceInstaller {
}
- List<IEntityDetails> serviceEntityList =
- getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.VF).customizationUUID(
- vnfResourceCustomization.getModelCustomizationUUID()), SdcTypes.SERVICE, false);
+ List<IEntityDetails> serviceEntityList = getEntityDetails(toscaResourceStructure,
+ EntityQuery.newBuilder(SdcTypes.VF)
+ .customizationUUID(vnfResourceCustomization.getModelCustomizationUUID()),
+ TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
if (serviceEntityList != null && !serviceEntityList.isEmpty()) {
vfcInstanceGroupCustom.setFunction(getLeafPropertyValue(serviceEntityList.get(0), getInputName));
@@ -1966,22 +2020,26 @@ public class ToscaResourceInstaller {
return jsonStr;
}
- protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
+ protected VfModuleCustomization createVFModuleResource(IEntityDetails vfModuleEntityDetails,
ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
- IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Set<CvnfcCustomization> existingCvnfcSet,
- Set<VnfcCustomization> existingVnfcSet,
+ IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
+ Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet,
List<CvnfcConfigurationCustomization> existingCvnfcConfigurationCustom) {
VfModuleCustomization vfModuleCustomization =
findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
+
if (vfModuleCustomization == null) {
+
VfModule vfModule = findExistingVfModule(vnfResource,
- vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- Metadata vfMetadata = group.getMetadata();
+ vfModuleEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+
+ Metadata vfMetadata = vfModuleEntityDetails.getMetadata();
if (vfModule == null)
- vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
+ vfModule = createVfModule(vfModuleEntityDetails, toscaResourceStructure, vfModuleData, vfMetadata);
- vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
+ vfModuleCustomization =
+ createVfModuleCustomization(vfModuleEntityDetails, toscaResourceStructure, vfModule, vfModuleData);
vfModuleCustomization.setVnfCustomization(vnfResource);
setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
vfMetadata);
@@ -2001,38 +2059,48 @@ public class ToscaResourceInstaller {
Set<VnfcCustomization> vnfcCustomizations = new HashSet<>();
// Only set the CVNFC if this vfModule group is a member of it.
- List<NodeTemplate> groupMembers =
- toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group);
- String vfModuleMemberName = null;
- for (NodeTemplate node : groupMembers) {
- vfModuleMemberName = node.getName();
- }
+ List<IEntityDetails> groupMembers = getEntityDetails(toscaResourceStructure,
+ EntityQuery.newBuilder("org.openecomp.groups.VfModule")
+ .uUID(vfModuleCustomization.getVfModule().getModelUUID()),
+ TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
+
+ String vfModuleMemberName = null;
// Extract CVFC lists
- List<IEntityDetails> cvnfcEntityList =
- getEntityDetails(toscaResourceStructure, SdcTypes.CVFC, SdcTypes.VF, false);
+ List<IEntityDetails> cvnfcEntityList = getEntityDetails(toscaResourceStructure,
+ EntityQuery.newBuilder(SdcTypes.CVFC), TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
+
for (IEntityDetails cvfcEntity : cvnfcEntityList) {
boolean cvnfcVfModuleNameMatch = false;
- for (NodeTemplate node : groupMembers) {
- vfModuleMemberName = node.getName();
+ for (IEntityDetails entity : groupMembers) {
+
+ List<IEntityDetails> groupMembersNodes = entity.getMemberNodes();
+ for (IEntityDetails groupMember : groupMembersNodes) {
+
+ vfModuleMemberName = groupMember.getName();
+
+ if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) {
+ cvnfcVfModuleNameMatch = true;
+ break;
+ }
- if (vfModuleMemberName.equalsIgnoreCase(cvfcEntity.getName())) {
- cvnfcVfModuleNameMatch = true;
- break;
}
}
+
if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
// Extract associated VFC - Should always be just one
- List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure, SdcTypes.VFC,
+ List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStructure,
+ EntityQuery.newBuilder(SdcTypes.VFC),
TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(
cvfcEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)),
false);
+
for (IEntityDetails vfcEntity : vfcEntityList) {
VnfcCustomization vnfcCustomization = new VnfcCustomization();
@@ -2102,37 +2170,48 @@ public class ToscaResourceInstaller {
cvnfcCustomization.setNfcNamingCode(getLeafPropertyValue(cvfcEntity, "nfc_naming_code"));
cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+
// *****************************************************************************************************************************************
// * Extract Fabric Configuration
// *****************************************************************************************************************************************
List<IEntityDetails> fabricEntityList =
- getEntityDetails(toscaResourceStructure, SdcTypes.CONFIGURATION, SdcTypes.VF, false);
+ getEntityDetails(toscaResourceStructure, EntityQuery.newBuilder(SdcTypes.CONFIGURATION),
+ TopologyTemplateQuery.newBuilder(SdcTypes.VF), false);
for (IEntityDetails fabricEntity : fabricEntityList) {
- ConfigurationResource fabricConfig = null;
+ Map<String, RequirementAssignment> requirements = fabricEntity.getRequirements();
- ConfigurationResource existingConfig =
- findExistingConfiguration(existingCvnfcConfigurationCustom,
+ for (RequirementAssignment requirement : requirements.values()) {
+
+ if (requirement.getNodeTemplateName().equals(cvfcEntity.getName())) {
+
+ ConfigurationResource fabricConfig = null;
+
+ ConfigurationResource existingConfig = findExistingConfiguration(
+ existingCvnfcConfigurationCustom,
fabricEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- if (existingConfig == null) {
+ if (existingConfig == null) {
- fabricConfig = createFabricConfiguration(fabricEntity, toscaResourceStructure);
+ fabricConfig = createFabricConfiguration(fabricEntity, toscaResourceStructure);
- } else {
- fabricConfig = existingConfig;
- }
+ } else {
+ fabricConfig = existingConfig;
+ }
- CvnfcConfigurationCustomization cvnfcConfigurationCustomization =
- createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure,
- vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig,
- vfTemplate, vfModuleMemberName);
+ CvnfcConfigurationCustomization cvnfcConfigurationCustomization =
+ createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure,
+ vnfResource, vfModuleCustomization, cvnfcCustomization,
+ fabricConfig, vfModuleMemberName);
- cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
+ cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
- existingCvnfcConfigurationCustom.add(cvnfcConfigurationCustomization);
+ existingCvnfcConfigurationCustom.add(cvnfcConfigurationCustomization);
+
+ }
+ }
}
cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
@@ -2153,7 +2232,7 @@ public class ToscaResourceInstaller {
protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(IEntityDetails fabricEntity,
ToscaResourceStructure toscaResourceStruct, VnfResourceCustomization vnfResource,
VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
- ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
+ ConfigurationResource configResource, String vfModuleMemberName) {
Metadata fabricMetadata = fabricEntity.getMetadata();
@@ -2168,7 +2247,9 @@ public class ToscaResourceInstaller {
cvnfcConfigurationCustomization.setModelInstanceName(fabricEntity.getName());
List<IEntityDetails> policyList =
- getEntityDetails(toscaResourceStruct, "org.openecomp.policies.External", SdcTypes.VF, true);
+ getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.policies.External"),
+ TopologyTemplateQuery.newBuilder(SdcTypes.VF), true);
+
if (policyList != null) {
for (IEntityDetails policyEntity : policyList) {
@@ -2245,7 +2326,7 @@ public class ToscaResourceInstaller {
return vfModule;
}
- protected VfModuleCustomization createVfModuleCustomization(Group group,
+ protected VfModuleCustomization createVfModuleCustomization(IEntityDetails vfModuleEntityDetails,
ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
@@ -2253,62 +2334,64 @@ public class ToscaResourceInstaller {
vfModuleCustomization.setVfModule(vfModule);
- String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
+ String initialCount = getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
+
+
if (initialCount != null && initialCount.length() > 0) {
vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
}
- vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
- .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
+ String availabilityZoneCount =
+ getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
- String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
}
- vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
+ vfModuleCustomization
+ .setLabel(getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
+
+ String maxInstances =
+ getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
- String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
if (maxInstances != null && maxInstances.length() > 0) {
vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
}
- String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
+ String minInstances =
+ getLeafPropertyValue(vfModuleEntityDetails, SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
+
if (minInstances != null && minInstances.length() > 0) {
vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
}
return vfModuleCustomization;
}
- protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
+ protected VfModule createVfModule(IEntityDetails groupEntityDetails, ToscaResourceStructure toscaResourceStructure,
IVfModuleData vfModuleData, Metadata vfMetadata) {
VfModule vfModule = new VfModule();
String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
if (vfModuleModelUUID == null) {
- vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+
+ vfModuleModelUUID = testNull(
+ groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+
} else if (vfModuleModelUUID.indexOf('.') > -1) {
vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
}
- vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
- vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
+ vfModule.setModelInvariantUUID(
+ groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));
+ vfModule.setModelName(
+ groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME));
vfModule.setModelUUID(vfModuleModelUUID);
- vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
- vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vfModule.setModelVersion(
+ groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION));
+ vfModule.setDescription(groupEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ String vfModuleType = getLeafPropertyValue(groupEntityDetails, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
- String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
vfModule.setIsBase(true);
} else {
@@ -2413,26 +2496,26 @@ public class ToscaResourceInstaller {
}
}
- protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
+ protected VnfResourceCustomization createVnfResource(IEntityDetails entityDetails,
ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException {
VnfResourceCustomization vnfResourceCustomization = null;
if (vnfResourceCustomization == null) {
+
VnfResource vnfResource = findExistingVnfResource(service,
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (vnfResource == null) {
- vnfResource = createVnfResource(vfNodeTemplate);
+ vnfResource = createVnfResource(entityDetails);
}
vnfResourceCustomization =
- createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, vnfResource);
+ createVnfResourceCustomization(entityDetails, toscaResourceStructure, vnfResource);
vnfResourceCustomization.setVnfResources(vnfResource);
vnfResourceCustomization.setService(service);
// setting resource input for vnf customization
vnfResourceCustomization.setResourceInput(
getResourceInput(toscaResourceStructure, vnfResourceCustomization.getModelCustomizationUUID()));
- service.getVnfCustomizations().add(vnfResourceCustomization);
}
return vnfResourceCustomization;
@@ -2452,61 +2535,56 @@ public class ToscaResourceInstaller {
return vnfResource;
}
- protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
+ protected VnfResourceCustomization createVnfResourceCustomization(IEntityDetails entityDetails,
ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
vnfResourceCustomization.setModelCustomizationUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
-
- vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
- vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+ entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
+ vnfResourceCustomization.setModelInstanceName(entityDetails.getName());
+ vnfResourceCustomization
+ .setNfFunction(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ vnfResourceCustomization.setNfNamingCode(getLeafPropertyValue(entityDetails, "nf_naming_code"));
+ vnfResourceCustomization.setNfRole(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ vnfResourceCustomization.setNfType(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+ vnfResourceCustomization.setMultiStageDesign(getLeafPropertyValue(entityDetails, MULTI_STAGE_DESIGN));
+ vnfResourceCustomization.setBlueprintName(getLeafPropertyValue(entityDetails, SDNC_MODEL_NAME));
+ vnfResourceCustomization.setBlueprintVersion(getLeafPropertyValue(entityDetails, SDNC_MODEL_VERSION));
- vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
+ String skipPostInstConfText = getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF);
- String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF);
if (skipPostInstConfText != null) {
- vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText));
+ vnfResourceCustomization.setSkipPostInstConf(
+ Boolean.parseBoolean(getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF)));
}
+
vnfResourceCustomization.setVnfResources(vnfResource);
vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
+ entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
+
+ entityDetails.getCapabilities().get(SCALABLE);
- CapabilityAssignments vnfCustomizationCapability =
- toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(vfNodeTemplate);
- if (vnfCustomizationCapability != null) {
- CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
+ if (entityDetails.getCapabilities() != null) {
+
+ CapabilityAssignment capAssign = entityDetails.getCapabilities().get(SCALABLE);
if (capAssign != null) {
- vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ 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) {
- vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ vnfResourceCustomization.setMinInstances(Integer
+ .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer
+ .getInteger(getLeafPropertyValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
}
toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
@@ -2514,44 +2592,44 @@ public class ToscaResourceInstaller {
return vnfResourceCustomization;
}
- protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
+ protected VnfResource createVnfResource(IEntityDetails entityDetails) {
VnfResource vnfResource = new VnfResource();
vnfResource.setModelInvariantUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ vnfResource.setModelName(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ vnfResource.setModelUUID(testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
vnfResource.setModelVersion(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
vnfResource.setDescription(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
vnfResource.setOrchestrationMode(HEAT);
- vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
+ vnfResource.setToscaNodeType(testNull(entityDetails.getToscaType()));
vnfResource.setAicVersionMax(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
vnfResource.setAicVersionMin(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
+ testNull(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResource.setCategory(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ vnfResource.setSubCategory(entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
return vnfResource;
}
- protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
+ protected AllottedResourceCustomization createAllottedResource(IEntityDetails arEntity,
ToscaResourceStructure toscaResourceStructure, Service service) {
AllottedResourceCustomization allottedResourceCustomization =
allottedCustomizationRepo.findOneByModelCustomizationUUID(
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
if (allottedResourceCustomization == null) {
AllottedResource allottedResource = findExistingAllottedResource(service,
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
if (allottedResource == null)
- allottedResource = createAR(nodeTemplate);
+ allottedResource = createAR(arEntity);
toscaResourceStructure.setAllottedResource(allottedResource);
- allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
+ allottedResourceCustomization = createAllottedResourceCustomization(arEntity, toscaResourceStructure);
allottedResourceCustomization.setAllottedResource(allottedResource);
allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
}
@@ -2572,73 +2650,81 @@ public class ToscaResourceInstaller {
return allottedResource;
}
- protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
+ protected AllottedResourceCustomization createAllottedResourceCustomization(IEntityDetails arEntity,
ToscaResourceStructure toscaResourceStructure) {
AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
allottedResourceCustomization.setModelCustomizationUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
+ testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ allottedResourceCustomization.setModelInstanceName(arEntity.getName());
+
+ allottedResourceCustomization
+ .setNfFunction(getLeafPropertyValue(arEntity, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ allottedResourceCustomization.setNfNamingCode(getLeafPropertyValue(arEntity, "nf_naming_code"));
+ allottedResourceCustomization.setNfRole(getLeafPropertyValue(arEntity, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ allottedResourceCustomization.setNfType(getLeafPropertyValue(arEntity, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.VFC).build();
- allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
- allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
+ .customizationUUID(allottedResourceCustomization.getModelCustomizationUUID()).build();
- List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper()
- .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
+ List<IEntityDetails> vfcEntities =
+ toscaResourceStructure.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, false);
- if (vfcNodes != null) {
- for (NodeTemplate vfcNode : vfcNodes) {
- allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
+ if (vfcEntities != null) {
+ for (IEntityDetails vfcEntity : vfcEntities) {
+
+ allottedResourceCustomization
+ .setProvidingServiceModelUUID(getLeafPropertyValue(vfcEntity, "providing_service_uuid"));
+ allottedResourceCustomization.setProvidingServiceModelInvariantUUID(
+ getLeafPropertyValue(vfcEntity, "providing_service_invariant_uuid"));
allottedResourceCustomization
- .setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
- allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
+ .setProvidingServiceModelName(getLeafPropertyValue(vfcEntity, "providing_service_name"));
}
}
+ Map<String, CapabilityAssignment> capAssignmentList = arEntity.getCapabilities();
- CapabilityAssignments arCustomizationCapability =
- toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(nodeTemplate);
+ if (capAssignmentList != null) {
- if (arCustomizationCapability != null) {
- CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
+ for (Map.Entry<String, CapabilityAssignment> entry : capAssignmentList.entrySet()) {
+ CapabilityAssignment arCapability = entry.getValue();
+
+ if (arCapability != null) {
+
+ String capabilityName = arCapability.getName();
+
+ if (capabilityName.equals(SCALABLE)) {
+
+ allottedResourceCustomization
+ .setMinInstances(Integer.getInteger(getCapabilityLeafPropertyValue(arCapability,
+ SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ allottedResourceCustomization
+ .setMinInstances(Integer.getInteger(getCapabilityLeafPropertyValue(arCapability,
+ SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+
+ }
+ }
- if (capAssign != null) {
- allottedResourceCustomization.setMinInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- allottedResourceCustomization.setMaxInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
}
}
+
return allottedResourceCustomization;
}
- protected AllottedResource createAR(NodeTemplate nodeTemplate) {
+ protected AllottedResource createAR(IEntityDetails arEntity) {
AllottedResource allottedResource = new AllottedResource();
- allottedResource
- .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ allottedResource.setModelUUID(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
allottedResource.setModelInvariantUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ allottedResource.setModelName(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
allottedResource
- .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ .setModelVersion(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ allottedResource.setToscaNodeType(testNull(arEntity.getToscaType()));
allottedResource
- .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
- allottedResource.setSubcategory(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- allottedResource
- .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ .setSubcategory(testNull(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ allottedResource.setDescription(arEntity.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
return allottedResource;
}
@@ -2707,46 +2793,10 @@ public class ToscaResourceInstaller {
+ vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
}
- protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, SdcTypes entityType,
- SdcTypes topologyTemplate, boolean nestedSearch) {
-
- EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build();
- List<IEntityDetails> entityDetails =
- toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
-
- return entityDetails;
-
- }
-
- protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, String entityType,
- SdcTypes topologyTemplate, boolean nestedSearch) {
-
- EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build();
- List<IEntityDetails> entityDetails =
- toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
-
- return entityDetails;
-
- }
-
- protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, String entityType,
- TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) {
-
- EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build();
- TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build();
- List<IEntityDetails> entityDetails =
- toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
-
- return entityDetails;
-
- }
-
- protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct, SdcTypes entityType,
- TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) {
+ protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct,
+ EntityQueryBuilder entityType, TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) {
- EntityQuery entityQuery = EntityQuery.newBuilder(entityType).build();
+ EntityQuery entityQuery = entityType.build();
TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build();
List<IEntityDetails> entityDetails =
toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
@@ -2755,21 +2805,20 @@ public class ToscaResourceInstaller {
}
- protected List<IEntityDetails> getEntityDetails(ToscaResourceStructure toscaResourceStruct,
- EntityQueryBuilder entityType, SdcTypes topologyTemplate, boolean nestedSearch) {
+ protected String getLeafPropertyValue(IEntityDetails entityDetails, String propName) {
- EntityQuery entityQuery = entityType.build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build();
- List<IEntityDetails> entityDetails =
- toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
+ Property leafProperty = entityDetails.getProperties().get(propName);
- return entityDetails;
+ if (leafProperty != null && leafProperty.getValue() != null) {
+ return leafProperty.getValue().toString();
+ }
+ return null;
}
- protected String getLeafPropertyValue(IEntityDetails entityDetails, String propName) {
+ protected String getCapabilityLeafPropertyValue(CapabilityAssignment capAssign, String propName) {
- Property leafProperty = entityDetails.getProperties().get(propName);
+ Property leafProperty = capAssign.getProperties().get(propName);
if (leafProperty != null && leafProperty.getValue() != null) {
return leafProperty.getValue().toString();
@@ -2784,8 +2833,9 @@ public class ToscaResourceInstaller {
if (propertyName != null) {
int getInputIndex = propertyName.indexOf("{get_input=");
+ int getClosingIndex = propertyName.indexOf("}");
if (getInputIndex > -1) {
- inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1);
+ inputName = propertyName.substring(getInputIndex + 11, getClosingIndex);
}
}
@@ -2799,10 +2849,18 @@ public class ToscaResourceInstaller {
if (!services.isEmpty()) {
// service exist in db
Service existingService = services.get(0);
- List<VnfResourceCustomization> vnfCustomizations = existingService.getVnfCustomizations();
- vnfCustomizations.forEach(e -> service.getVnfCustomizations().add(e));
+ List<VnfResourceCustomization> existingVnfCustomizations = existingService.getVnfCustomizations();
+ if (existingService != null) {
+ // it is duplicating entries, so added a check
+ for (VnfResourceCustomization existingVnfResourceCustomization : existingVnfCustomizations) {
+ if (!service.getVnfCustomizations().contains(existingVnfResourceCustomization)) {
+ service.getVnfCustomizations().add(existingVnfResourceCustomization);
+ }
+ }
+ }
}
service.getVnfCustomizations().add(vnfResourceCustomization);
+
}
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 a154734690..4b069e6ac7 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
@@ -724,6 +724,9 @@ public class ASDCNotificationLogging {
buffer.append("Model Subcategory:");
buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
buffer.append(System.lineSeparator());
+ buffer.append("Model Category:");
+ buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ buffer.append(System.lineSeparator());
buffer.append("Model Description:");
buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
buffer.append(System.lineSeparator());