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.java24
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java97
2 files changed, 85 insertions, 36 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 ad96e1be4b..44ea2a25a2 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
@@ -754,6 +754,12 @@ public class ASDCController {
}
// process NsstResource
this.processNsstNotification(iNotif, toscaResourceStructure);
+
+ if (iNotif.getResources().isEmpty()) {
+ logger.error("Service Model contains no resources.");
+ return;
+ }
+
for (IResourceInstance resource : iNotif.getResources()) {
String resourceType = resource.getResourceType();
@@ -965,8 +971,10 @@ public class ASDCController {
private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
try {
- if (serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY).equalsIgnoreCase("NSST")) {
-
+ String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement"))
+ && iNotif.getResources().isEmpty();
+ if (isNeedInital) {
String artifactContent = null;
List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream()
@@ -980,14 +988,18 @@ public class ASDCController {
artifactContent = zipParserInstance.parseJsonForZip(filePath);
logger.debug(
"serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
+
+ ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+ resourceStructure.setResourceType(ResourceType.OTHER);
+ toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure,
+ artifactContent);
} else {
logger.debug("serviceArtifact is null");
+ toscaInstaller.installNsstService(toscaResourceStructure, null, null);
}
- ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
- resourceStructure.setResourceType(ResourceType.OTHER);
- toscaInstaller.installTheNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure,
- artifactContent);
+
}
+
} catch (IOException e) {
logger.error("serviceArtifact parse failure for service uuid: "
+ serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
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 d023df3b79..49fef1d3f0 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
@@ -2870,7 +2870,15 @@ public class ToscaResourceInstaller {
List<Input> serviceInputs = sdcCsarHelper.getServiceInputs();
if (!serviceInputs.isEmpty()) {
serviceInputList = new ArrayList<>();
- serviceInputs.forEach(input -> {
+ List<Input> filterList;
+ filterList = serviceInputs.stream()
+ .filter(input -> !SKIP_POST_INST_CONF.equals(input.getName())
+ && !CDS_MODEL_NAME.equalsIgnoreCase(input.getName())
+ && !CDS_MODEL_VERSION.equalsIgnoreCase(input.getName())
+ && !CONTROLLER_ACTOR.equalsIgnoreCase(input.getName()))
+ .collect(Collectors.toList());
+
+ filterList.forEach(input -> {
Map<String, Object> serviceInputMap = new HashMap<>();
serviceInputMap.put("name", input.getName());
serviceInputMap.put("type", input.getType());
@@ -2894,7 +2902,7 @@ public class ToscaResourceInstaller {
}
@Transactional(rollbackFor = {ArtifactInstallerException.class})
- public void installTheNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct,
+ public void installNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct,
String artifactContent) {
createToscaCsar(toscaResourceStruct);
createService(toscaResourceStruct, vfResourceStruct);
@@ -2925,6 +2933,10 @@ public class ToscaResourceInstaller {
}
private void createServiceInfo(ToscaResourceStructure toscaResourceStruct, Service service) {
+ if (!service.getServiceInfos().isEmpty()) {
+ return;
+ }
+
List<ServiceInfo> serviceInfos = new ArrayList<>();
ServiceInfo serviceInfo = new ServiceInfo();
@@ -2945,42 +2957,67 @@ public class ToscaResourceInstaller {
ISdcCsarHelper helper = toscaResourceStruct.getSdcCsarHelper();
String typeName = helper.getServiceSubstitutionMappingsTypeName();
Optional<NodeTemplate> nodeTemplate = helper.getServiceNodeTemplates().stream().findAny();
- List<Object> serviceProperties = new ArrayList<>();
- Map<String, Object> servicePropertiesMap;
+
if (nodeTemplate.isPresent()) {
+ String serviceUUID = nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
LinkedHashMap<String, Object> customDef = nodeTemplate.get().getCustomDef();
- Optional<String> machKey =
- customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst();
- if (machKey.isPresent()) {
- Object obj = customDef.get(machKey.get());
- try {
- if (obj instanceof Map) {
- Object properties = ((HashMap) obj).get("properties");
- if (null != properties) {
- for (Object propertyName : ((Map) properties).keySet()) {
- servicePropertiesMap = new HashMap<>();
- servicePropertiesMap.put("name", propertyName);
- Object object = ((Map) properties).get(propertyName);
- for (Object entry : ((Map) object).entrySet()) {
- servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(),
- ((Map.Entry) entry).getValue());
- }
- servicePropertiesMap.remove("description");
- serviceProperties.add(servicePropertiesMap);
+ List<Object> serviceProperties = getPropertiesFromCustomDef(customDef, typeName);
+
+ try {
+ propertiesJson = objectMapper.writeValueAsString(serviceProperties);
+ propertiesJson = propertiesJson.replace("\"", "\\\"");
+ } catch (JsonProcessingException e) {
+ logger.error("serviceProperties could not be deserialized for service uuid: " + serviceUUID);
+ } catch (Exception ex) {
+ logger.error("service properties parsing failed. service uuid:" + serviceUUID);
+ }
+
+ } else {
+ logger.debug("ServiceNodeTemplates is null");
+ }
+ return propertiesJson;
+ }
+
+ private static List<Object> getPropertiesFromCustomDef(LinkedHashMap<String, Object> customDef,
+ final String typeName) {
+ Optional<String> machKey =
+ customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst();
+ Map<String, Object> servicePropertiesMap;
+ List<Object> serviceProperties = new ArrayList<>();
+
+ if (machKey.isPresent()) {
+ Object obj = customDef.get(machKey.get());
+ if (obj instanceof Map) {
+ Object properties = ((HashMap) obj).get("properties");
+ if (null != properties) {
+ for (Object propertyName : ((Map) properties).keySet()) {
+ if (propertyName.toString().split("_").length >= 2) {
+ continue;
+ }
+
+ servicePropertiesMap = new HashMap<>();
+ servicePropertiesMap.put("name", propertyName);
+ Object object = ((Map) properties).get(propertyName);
+ for (Object entry : ((Map) object).entrySet()) {
+ servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(),
+ ((Map.Entry) entry).getValue());
+ }
+
+ String type = servicePropertiesMap.get("type").toString();
+ if (type.split("\\.").length >= 2) {
+ List<Object> subProperties = getPropertiesFromCustomDef(customDef, type);
+ if (subProperties.size() > 0) {
+ serviceProperties.addAll(subProperties);
}
- propertiesJson = objectMapper.writeValueAsString(serviceProperties);
- propertiesJson = propertiesJson.replace("\"", "\\\"");
+ continue;
}
+ servicePropertiesMap.remove("description");
+ serviceProperties.add(servicePropertiesMap);
}
- } catch (JsonProcessingException e) {
- logger.error("serviceProperties could not be deserialized for service uuid: "
- + nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
}
}
- } else {
- logger.debug("ServiceNodeTemplates is null");
}
- return propertiesJson;
+ return serviceProperties;
}
}