summaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller')
-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.java364
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java27
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java219
-rw-r--r--asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json57
-rw-r--r--asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csarbin0 -> 45576 bytes
6 files changed, 490 insertions, 184 deletions
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 073412133c..90116ad4f5 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
@@ -742,8 +742,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);
@@ -761,8 +760,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..08aee1ab4e 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
@@ -434,12 +434,20 @@ 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);
+
+ for (IEntityDetails vfEntityDetails : vfEntityList) {
+
+ Metadata metadata = vfEntityDetails.getMetadata();
+ String category = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+
+ if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) {
+ continue;
+ }
+
+ processVfModules(vfEntityDetails, vfNodeTemplatesList.get(0), toscaResourceStruct, vfResourceStructure,
+ service, metadata);
}
processResourceSequence(toscaResourceStruct, service);
@@ -631,7 +639,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) {
@@ -655,6 +664,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);
@@ -665,11 +676,14 @@ public class ToscaResourceInstaller {
}
protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
- List<NodeTemplate> allottedResourceList) {
+ List<NodeTemplate> allottedResourceList) throws ArtifactInstallerException {
if (allottedResourceList != null) {
for (NodeTemplate allottedNode : allottedResourceList) {
- service.getAllottedCustomizations()
- .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
+ AllottedResourceCustomization allottedResource =
+ createAllottedResource(allottedNode, toscaResourceStruct, service);
+ allottedResource.setResourceInput(
+ getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID()));
+ service.getAllottedCustomizations().add(allottedResource);
}
}
}
@@ -954,17 +968,21 @@ 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 = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata,
- SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ String vfCustomizationUUID =
+ vfEntityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+
logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
@@ -980,7 +998,7 @@ public class ToscaResourceInstaller {
logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ " matches vfNotificationResource CustomizationUUID");
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+ VnfResourceCustomization vnfResource = createVnfResource(vfEntityDetails, toscaResourceStruct, service);
Set<CvnfcCustomization> existingCvnfcSet = new HashSet<>();
Set<VnfcCustomization> existingVnfcSet = new HashSet<>();
@@ -989,14 +1007,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 +1027,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
@@ -1017,7 +1040,7 @@ public class ToscaResourceInstaller {
// Check for VNFC Instance Group info and add it if there is
List<IEntityDetails> vfcEntityList = getEntityDetails(toscaResourceStruct,
- "org.openecomp.groups.VfcInstanceGroup",
+ EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup"),
TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(vfCustomizationUUID), false);
@@ -1349,7 +1372,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,7 +1491,14 @@ 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 = toscaCsarOpt.get();
+ } else {
+ toscaCsar = new ToscaCsar();
+ }
if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
} else {
@@ -1891,9 +1928,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 +2004,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 +2043,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();
@@ -2107,7 +2159,9 @@ public class ToscaResourceInstaller {
// *****************************************************************************************************************************************
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) {
@@ -2128,7 +2182,7 @@ public class ToscaResourceInstaller {
CvnfcConfigurationCustomization cvnfcConfigurationCustomization =
createCvnfcConfigurationCustomization(fabricEntity, toscaResourceStructure,
vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig,
- vfTemplate, vfModuleMemberName);
+ vfModuleMemberName);
cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
@@ -2153,7 +2207,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 +2222,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 +2301,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 +2309,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,19 +2471,20 @@ 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);
@@ -2452,61 +2511,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());
+ entityDetails.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- 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)));
+ 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.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
+ vnfResourceCustomization.setMultiStageDesign(getLeafPropertyValue(entityDetails, MULTI_STAGE_DESIGN));
+ vnfResourceCustomization.setBlueprintName(getLeafPropertyValue(entityDetails, SDNC_MODEL_NAME));
+ vnfResourceCustomization.setBlueprintVersion(getLeafPropertyValue(entityDetails, SDNC_MODEL_VERSION));
- vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+ String skipPostInstConfText = getLeafPropertyValue(entityDetails, SKIP_POST_INST_CONF);
- vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
-
- 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,25 +2568,25 @@ 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;
}
@@ -2707,59 +2761,11 @@ 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) {
-
- 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,
- EntityQueryBuilder entityType, SdcTypes topologyTemplate, boolean nestedSearch) {
+ EntityQueryBuilder entityType, TopologyTemplateQueryBuilder topologyTemplateBuilder, boolean nestedSearch) {
EntityQuery entityQuery = entityType.build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(topologyTemplate).build();
+ TopologyTemplateQuery topologyTemplateQuery = topologyTemplateBuilder.build();
List<IEntityDetails> entityDetails =
toscaResourceStruct.getSdcCsarHelper().getEntity(entityQuery, topologyTemplateQuery, nestedSearch);
@@ -2799,8 +2805,10 @@ 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) {
+ service.getVnfCustomizations().addAll(existingVnfCustomizations);
+ }
}
service.getVnfCustomizations().add(vnfResourceCustomization);
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index 2c520a3bba..cfcf5ac599 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -144,6 +144,7 @@ public class ASDCRestInterfaceTest extends BaseTest {
AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
arCustomization.setModelInstanceName("rege1802pnf 0");
+ arCustomization.setResourceInput("{}");
arCustomizationSet.add(arCustomization);
arCustomization.setAllottedResource(expectedService);
@@ -164,7 +165,7 @@ public class ASDCRestInterfaceTest extends BaseTest {
@Test
@Transactional
- public void test_VFW_Distrobution() throws Exception {
+ public void test_VFW_Distribution() throws Exception {
wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
.willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
@@ -290,6 +291,30 @@ public class ASDCRestInterfaceTest extends BaseTest {
assertEquals("Generic NeutronNet", networkResource.get().getModelName());
}
+ @Test
+ public void test_CCVPN_Distribution() throws Exception {
+ wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
+
+ wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withStatus(org.springframework.http.HttpStatus.ACCEPTED.value())));
+
+ String resourceLocation = "src/test/resources/resource-examples/ccvpn/";
+ ObjectMapper mapper = new ObjectMapper();
+ NotificationDataImpl request = mapper.readValue(new File(resourceLocation + "demo-ccvpn-notification.json"),
+ NotificationDataImpl.class);
+ headers.add("resource-location", resourceLocation);
+ HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
+ ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"),
+ HttpMethod.POST, entity, String.class);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
+ Optional<Service> service = serviceRepo.findById("5c4d4793-67fb-4155-b7d8-60ec011138c9");
+ assertTrue(service.isPresent());
+ assertEquals("SDWAN", service.get().getModelName());
+ }
+
protected String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
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 7534ea645a..ffad137ad7 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
@@ -25,16 +25,19 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.hibernate.exception.LockAcquisitionException;
import org.junit.Before;
@@ -54,26 +57,38 @@ import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
import org.onap.sdc.toscaparser.api.RequirementAssignments;
+import org.onap.sdc.toscaparser.api.SubstitutionMappings;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.toscaparser.api.elements.StatefulEntityType;
+import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.sdc.utils.DistributionStatusEnum;
import org.onap.so.asdc.BaseTest;
+import org.onap.so.asdc.client.ResourceInstance;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl;
import org.onap.so.asdc.client.test.emulators.JsonStatusData;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
+import org.onap.so.asdc.installer.IVfModuleData;
import org.onap.so.asdc.installer.ResourceStructure;
import org.onap.so.asdc.installer.ToscaResourceStructure;
+import org.onap.so.asdc.installer.VfModuleStructure;
+import org.onap.so.asdc.installer.VfResourceStructure;
+import org.onap.so.asdc.installer.bpmn.WorkflowResource;
import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
import org.onap.so.db.catalog.beans.ToscaCsar;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
+import org.onap.so.db.catalog.data.repository.VFModuleRepository;
+import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
+import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
@@ -111,6 +126,8 @@ public class ToscaResourceInstallerTest extends BaseTest {
@Mock
private ToscaResourceStructure toscaResourceStructure;
@Mock
+ private VfResourceStructure vfResourceStruct;
+ @Mock
private ServiceProxyResourceCustomization spResourceCustomization;
@Mock
private ISdcCsarHelper csarHelper;
@@ -258,6 +275,206 @@ public class ToscaResourceInstallerTest extends BaseTest {
}
@Test
+ public void installTheResourceWithGroupAndVFModulesTest() throws Exception {
+ ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructObj = prepareToscaResourceStructure(true, toscaInstaller);
+
+ toscaInstaller.installTheResource(toscaResourceStructObj, vfResourceStruct);
+ assertEquals(true, toscaResourceStructObj.isDeployedSuccessfully());
+ }
+
+ @Test
+ public void installTheResourceGroupWithoutVFModulesTest() throws Exception {
+ ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructObj = prepareToscaResourceStructure(false, toscaInstaller);
+
+ toscaInstaller.installTheResource(toscaResourceStructObj, vfResourceStruct);
+ assertEquals(true, toscaResourceStructObj.isDeployedSuccessfully());
+ }
+
+ private ToscaResourceStructure prepareToscaResourceStructure(boolean prepareVFModuleStructures,
+ ToscaResourceInstaller toscaInstaller) throws ArtifactInstallerException {
+
+ Metadata metadata = mock(Metadata.class);
+ IResourceInstance resourceInstance = mock(ResourceInstance.class);
+ NodeTemplate nodeTemplate = mock(NodeTemplate.class);
+ ISdcCsarHelper csarHelper = mock(SdcCsarHelperImpl.class);
+
+ IArtifactInfo inputCsar = mock(IArtifactInfo.class);
+ String artifactUuid = "0122c05e-e13a-4c63-b5d2-475ccf23aa74";
+ String checkSum = "MGUzNjJjMzk3OTBkYzExYzQ0MDg2ZDc2M2E3ZjZiZmY=";
+
+ doReturn(checkSum).when(inputCsar).getArtifactChecksum();
+ doReturn(artifactUuid).when(inputCsar).getArtifactUUID();
+ doReturn("1.0").when(inputCsar).getArtifactVersion();
+ doReturn("TestCsarWithGroupAndVFModule").when(inputCsar).getArtifactName();
+ doReturn("Test Csar data with Group and VF module inputs").when(inputCsar).getArtifactDescription();
+ doReturn("http://localhost/dummy/url/test.csar").when(inputCsar).getArtifactURL();
+
+ ToscaResourceStructure toscaResourceStructObj = new ToscaResourceStructure();
+ toscaResourceStructObj.setToscaArtifact(inputCsar);
+
+ ToscaCsarRepository toscaCsarRepo = spy(ToscaCsarRepository.class);
+
+
+ ToscaCsar toscaCsar = mock(ToscaCsar.class);
+ Optional<ToscaCsar> returnValue = Optional.of(toscaCsar);
+ doReturn(artifactUuid).when(toscaCsar).getArtifactUUID();
+ doReturn(checkSum).when(toscaCsar).getArtifactChecksum();
+ doReturn(returnValue).when(toscaCsarRepo).findById(artifactUuid);
+
+ ReflectionTestUtils.setField(toscaInstaller, "toscaCsarRepo", toscaCsarRepo);
+
+ NotificationDataImpl notificationData = new NotificationDataImpl();
+ notificationData.setDistributionID("testStatusSuccessfulTosca");
+ notificationData.setServiceVersion("1234567");
+ notificationData.setServiceUUID("serviceUUID1");
+ notificationData.setWorkloadContext("workloadContext1");
+
+
+
+ String serviceType = "test-type1";
+ String serviceRole = "test-role1";
+ String category = "Network L3+";
+ String description = "Customer Orderable service description";
+ String name = "Customer_Orderable_Service";
+ String uuid = "72db5868-4575-4804-b546-0b0d3c3b5ac6";
+ String invariantUUID = "6f30bbe3-4590-4185-a7e0-4f9610926c6f";
+ String namingPolicy = "naming Policy1";
+ String ecompGeneratedNaming = "true";
+ String environmentContext = "General_Revenue-Bearing1";
+ String resourceCustomizationUUID = "0177ba22-5547-4e4e-bcf8-178f7f71de3a";
+
+ doReturn(serviceType).when(metadata).getValue("serviceType");
+ doReturn(serviceRole).when(metadata).getValue("serviceRole");
+
+ doReturn(category).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ doReturn(description).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
+ doReturn("1.0").when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION);
+ doReturn(name).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+
+ doReturn(uuid).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+
+ doReturn(environmentContext).when(metadata).getValue(metadata.getValue("environmentContext"));
+ doReturn(invariantUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
+ doReturn(namingPolicy).when(metadata).getValue("namingPolicy");
+ doReturn(ecompGeneratedNaming).when(metadata).getValue("ecompGeneratedNaming");
+ doReturn(resourceCustomizationUUID).when(metadata).getValue("vfModuleModelCustomizationUUID");
+
+ ServiceRepository serviceRepo = spy(ServiceRepository.class);
+
+ VnfResourceRepository vnfRepo = spy(VnfResourceRepository.class);
+ doReturn(null).when(vnfRepo).findResourceByModelUUID(uuid);
+
+ VFModuleRepository vfModuleRepo = spy(VFModuleRepository.class);
+ InstanceGroupRepository instanceGroupRepo = spy(InstanceGroupRepository.class);
+
+ WorkflowResource workflowResource = spy(WorkflowResource.class);
+
+ ReflectionTestUtils.setField(toscaInstaller, "serviceRepo", serviceRepo);
+ ReflectionTestUtils.setField(toscaInstaller, "vnfRepo", vnfRepo);
+ ReflectionTestUtils.setField(toscaInstaller, "vfModuleRepo", vfModuleRepo);
+ ReflectionTestUtils.setField(toscaInstaller, "instanceGroupRepo", instanceGroupRepo);
+ ReflectionTestUtils.setField(toscaInstaller, "workflowResource", workflowResource);
+
+ // doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
+ toscaResourceStructObj.setSdcCsarHelper(csarHelper);
+ 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(resourceCustomizationUUID).when(csarHelper).getMetadataPropertyValue(metadata,
+ SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ doReturn(uuid).when(csarHelper).getMetadataPropertyValue(metadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID);
+
+
+ // vnfc instance group list
+ List<Group> vnfcInstanceGroupList = new ArrayList<>();
+ Group vnfcG1 = mock(Group.class);
+ Map<String, Object> metaProperties = new HashMap<>();
+ metaProperties.put(SdcPropertyNames.PROPERTY_NAME_UUID, "vnfc_group1_uuid");
+ metaProperties.put(SdcPropertyNames.PROPERTY_NAME_NAME, "vnfc_group1_uuid");
+ metaProperties.put(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID, "vnfc_group1_invariantid");
+ metaProperties.put(SdcPropertyNames.PROPERTY_NAME_VERSION, "1.0");
+ Metadata vnfcmetadata = new Metadata(metaProperties);
+
+ doReturn(vnfcmetadata).when(vnfcG1).getMetadata();
+ ArrayList<NodeTemplate> memberList = new ArrayList();
+ doReturn(memberList).when(vnfcG1).getMemberNodes();
+ vnfcInstanceGroupList.add(vnfcG1);
+ SubstitutionMappings submappings = mock(SubstitutionMappings.class);
+ doReturn(new ArrayList<Input>()).when(submappings).getInputs();
+ doReturn(submappings).when(nodeTemplate).getSubMappingToscaTemplate();
+
+ doReturn(vnfcInstanceGroupList).when(csarHelper).getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate,
+ "org.openecomp.groups.VfcInstanceGroup");
+
+
+ doReturn(notificationData).when(vfResourceStruct).getNotification();
+ doReturn(resourceInstance).when(vfResourceStruct).getResourceInstance();
+
+ if (prepareVFModuleStructures) {
+
+ // VfModule list
+ List<Group> vfModuleGroups = new ArrayList<>();
+ Group g1 = mock(Group.class);
+ doReturn(metadata).when(g1).getMetadata();
+ vfModuleGroups.add(g1);
+
+ doReturn(vfModuleGroups).when(csarHelper).getVfModulesByVf(resourceCustomizationUUID);
+ doReturn("1").when(csarHelper).getGroupPropertyLeafValue(g1, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
+
+ doReturn(metadata).when(nodeTemplate).getMetaData();
+ List<NodeTemplate> nodeList = new ArrayList<>();
+ nodeList.add(nodeTemplate);
+ doReturn(nodeList).when(csarHelper).getServiceVfList();
+
+ IVfModuleData moduleMetadata = mock(IVfModuleData.class);
+ doReturn(name).when(moduleMetadata).getVfModuleModelName();
+ doReturn(invariantUUID).when(moduleMetadata).getVfModuleModelInvariantUUID();
+ doReturn(Collections.<String>emptyList()).when(moduleMetadata).getArtifacts();
+ doReturn(resourceCustomizationUUID).when(moduleMetadata).getVfModuleModelCustomizationUUID();
+ doReturn(uuid).when(moduleMetadata).getVfModuleModelUUID();
+ doReturn("1.0").when(moduleMetadata).getVfModuleModelVersion();
+
+ VfModuleStructure moduleStructure = new VfModuleStructure(vfResourceStruct, moduleMetadata);
+
+ List<VfModuleStructure> moduleStructures = new ArrayList<>();
+ moduleStructures.add(moduleStructure);
+ doReturn(moduleStructures).when(vfResourceStruct).getVfModuleStructure();
+ }
+
+ toscaResourceStructObj.setServiceMetadata(metadata);
+ doReturn("resourceInstanceName1").when(resourceInstance).getResourceInstanceName();
+ doReturn(resourceCustomizationUUID).when(resourceInstance).getResourceCustomizationUUID();
+ doReturn("resourceName1").when(resourceInstance).getResourceName();
+
+ Service service = toscaInstaller.createService(toscaResourceStructObj, vfResourceStruct);
+
+ assertNotNull(service);
+ service.setModelVersion("1.0");
+
+ doReturn(service).when(serviceRepo).save(service);
+
+ WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository =
+ spy(WatchdogComponentDistributionStatusRepository.class);
+ ReflectionTestUtils.setField(toscaInstaller, "watchdogCDStatusRepository", watchdogCDStatusRepository);
+ doReturn(null).when(watchdogCDStatusRepository).save(any(WatchdogComponentDistributionStatus.class));
+
+ VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo =
+ spy(VnfcInstanceGroupCustomizationRepository.class);
+ ReflectionTestUtils.setField(toscaInstaller, "vnfcInstanceGroupCustomizationRepo",
+ vnfcInstanceGroupCustomizationRepo);
+ doReturn(null).when(vnfcInstanceGroupCustomizationRepo).save(any(VnfcInstanceGroupCustomization.class));
+ return toscaResourceStructObj;
+ }
+
+
+
+ @Test
public void installTheResourceExceptionTest() throws Exception {
expectedException.expect(ArtifactInstallerException.class);
diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json
new file mode 100644
index 0000000000..bc7d7d7979
--- /dev/null
+++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/demo-ccvpn-notification.json
@@ -0,0 +1,57 @@
+{
+ "distributionID": "cbc7ab24-7d96-4cb5-949c-f23ada265513",
+ "serviceName": "SDWAN",
+ "serviceVersion": "2.0",
+ "serviceUUID": "5c4d4793-67fb-4155-b7d8-60ec011138c9",
+ "serviceDescription": "SDWAN Service",
+ "serviceInvariantUUID": "e830c260-ee21-4830-980c-c802cd9bbb1c",
+ "resources": [
+ {
+ "resourceInstanceName": "siteVF 0",
+ "resourceName": "siteVF",
+ "resourceVersion": "1.0",
+ "resoucreType": "VF",
+ "resourceUUID": "2c10d85c-e492-4813-a2d6-d1fab757fe49",
+ "resourceInvariantUUID": "ed9b1fe5-1e94-4974-a48f-389571837fd6",
+ "resourceCustomizationUUID": "33de5105-edf3-48cb-bda0-37b2aa2f681f",
+ "category": "Configuration",
+ "subcategory": "Configuration",
+ "artifacts": []
+ },
+ {
+ "resourceInstanceName": "vpn 0",
+ "resourceName": "vpn",
+ "resourceVersion": "2.0",
+ "resoucreType": "VF",
+ "resourceUUID": "235861f1-ea93-4443-94fa-82f29903f54f",
+ "resourceInvariantUUID": "c4eff5e7-c4fe-4caf-989b-11efc8e42a73",
+ "resourceCustomizationUUID": "faa89d44-329b-4fcb-a5dc-6e6f84946537",
+ "category": "Configuration",
+ "subcategory": "Configuration",
+ "artifacts": []
+ }
+ ],
+ "serviceArtifacts": [
+ {
+ "artifactName": "service-Sdwan-template.yml",
+ "artifactType": "TOSCA_TEMPLATE",
+ "artifactURL": "/sdc/v1/catalog/services/Sdwan/2.0/artifacts/service-Sdwan-template.yml",
+ "artifactChecksum": "Zjg4MmJmNzI1MTliYzBiZjA2ZmJjN2EwNzZhZTcxYTQ=",
+ "artifactDescription": "TOSCA representation of the asset",
+ "artifactTimeout": 0,
+ "artifactUUID": "5e7beb91-61f9-4613-8cc5-1d288a624abb",
+ "artifactVersion": "2"
+ },
+ {
+ "artifactName": "service-Sdwan-csar.csar",
+ "artifactType": "TOSCA_CSAR",
+ "artifactURL": "/service-Sdwan-csar.csar",
+ "artifactChecksum": "ODA1ZGViMzI0NzIxMmRmNTIzYzE0ZTg5NmExYWFjZTE=",
+ "artifactDescription": "TOSCA definition package of the asset",
+ "artifactTimeout": 0,
+ "artifactUUID": "771ec21a-1d14-4891-a56f-d4e47e2c8c91",
+ "artifactVersion": "2"
+ }
+ ],
+ "workloadContext": "Production"
+} \ No newline at end of file
diff --git a/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar
new file mode 100644
index 0000000000..7a508429f8
--- /dev/null
+++ b/asdc-controller/src/test/resources/resource-examples/ccvpn/service-Sdwan-csar.csar
Binary files differ