aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java5
-rw-r--r--src/main/java/org/onap/clamp/clds/model/CldsModel.java59
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java37
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java73
-rw-r--r--src/main/resources/clds/camel/flexible-flow.xml1
5 files changed, 127 insertions, 48 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java b/src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java
index b26310400..a78e895f7 100644
--- a/src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java
@@ -39,6 +39,7 @@ import java.util.List;
public class BlueprintParserMappingConfiguration {
private String blueprintKey;
+ private boolean dcaeDeployable;
private BlueprintParserFilesConfiguration files;
public String getBlueprintKey() {
@@ -57,6 +58,10 @@ public class BlueprintParserMappingConfiguration {
this.files = filesConfig;
}
+ public boolean isDcaeDeployable() {
+ return dcaeDeployable;
+ }
+
public static List<BlueprintParserMappingConfiguration> createFromJson(InputStream json) throws IOException {
TypeReference<List<BlueprintParserMappingConfiguration>> mapType = new TypeReference<List<BlueprintParserMappingConfiguration>>() {
};
diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
index 02c70cae0..34876bbc0 100644
--- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java
+++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java
@@ -43,33 +43,36 @@ import org.onap.clamp.clds.dao.CldsDao;
*/
public class CldsModel {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class);
- private static final int UUID_LENGTH = 36;
- private static final String STATUS_DESIGN = "DESIGN";
- private static final String STATUS_DISTRIBUTED = "DISTRIBUTED";
- private static final String STATUS_ACTIVE = "ACTIVE";
- private static final String STATUS_STOPPED = "STOPPED";
- private static final String STATUS_DELETING = "DELETING";
- private static final String STATUS_ERROR = "ERROR";
- private static final String STATUS_UNKNOWN = "UNKNOWN";
- private String id;
- private String templateId;
- private String templateName;
- private String name;
- private String controlNamePrefix;
- private String controlNameUuid;
- private String bpmnText;
- private String propText;
- private String imageText;
- private String docText;
- private String blueprintText;
- private CldsEvent event;
- private String status;
- private List<String> permittedActionCd;
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class);
+ private static final int UUID_LENGTH = 36;
+ private static final String STATUS_DESIGN = "DESIGN";
+ private static final String STATUS_DISTRIBUTED = "DISTRIBUTED";
+ private static final String STATUS_ACTIVE = "ACTIVE";
+ private static final String STATUS_STOPPED = "STOPPED";
+ private static final String STATUS_DELETING = "DELETING";
+ private static final String STATUS_ERROR = "ERROR";
+ private static final String STATUS_UNKNOWN = "UNKNOWN";
+ private String id;
+ private String templateId;
+ private String templateName;
+ private String name;
+ private String controlNamePrefix;
+ private String controlNameUuid;
+ private String bpmnText;
+ private String propText;
+ private String imageText;
+ private String docText;
+ private String blueprintText;
+ private CldsEvent event;
+ private String status;
+ private List<String> permittedActionCd;
private List<CldsModelInstance> cldsModelInstanceList;
- private String typeId;
- private String typeName;
- private String deploymentId;
+ /**
+ * The service type Id received from DCAE by querying it
+ */
+ private String typeId;
+ private String typeName;
+ private String deploymentId;
/**
* Construct empty model.
@@ -95,7 +98,6 @@ public class CldsModel {
public boolean canInventoryCall() {
boolean canCall = false;
/* Below checks the clds event is submit/resubmit */
-
if ((event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT)
|| event.isActionCd(CldsEvent.ACTION_SUBMITDCAE))) {
canCall = true;
@@ -116,7 +118,6 @@ public class CldsModel {
* set the status in the model
*/
private void determineStatus() {
-
status = STATUS_UNKNOWN;
if (event == null || event.getActionCd() == null) {
status = STATUS_DESIGN;
@@ -141,7 +142,6 @@ public class CldsModel {
} else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_ANY)) {
status = STATUS_STOPPED;
}
-
}
/**
@@ -491,5 +491,4 @@ public class CldsModel {
public List<String> getPermittedActionCd() {
return permittedActionCd;
}
-
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
index 940b7cfaf..b11385239 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
@@ -43,6 +43,7 @@ import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.openecomp.sdc.api.notification.IArtifactInfo;
import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
@@ -61,9 +62,14 @@ public class CsarHandler {
private SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
private ISdcCsarHelper sdcCsarHelper;
private String dcaeBlueprint;
+ private String blueprintArtifactName;
+ private String blueprintInvariantResourceUuid;
+ private String blueprintInvariantServiceUuid;
public static final String CSAR_TYPE = "TOSCA_CSAR";
+ private INotificationData sdcNotification;
public CsarHandler(INotificationData iNotif, String controller, String clampCsarPath) throws CsarHandlerException {
+ this.sdcNotification = iNotif;
this.controllerName = controller;
this.artifactElement = searchForUniqueCsar(iNotif);
this.csarFilePath = buildFilePathForCsar(artifactElement, clampCsarPath);
@@ -96,12 +102,27 @@ public class CsarHandler {
}
sdcCsarHelper = factory.getSdcCsarHelper(csarFilePath);
this.loadDcaeBlueprint();
+ this.loadBlueprintArtifactDetails();
} catch (IOException e) {
throw new SdcArtifactInstallerException(
"Exception caught when trying to write the CSAR on the file system to " + csarFilePath, e);
}
}
+ private void loadBlueprintArtifactDetails() {
+ blueprintInvariantServiceUuid = this.getSdcNotification().getServiceInvariantUUID();
+ for (IResourceInstance resource : this.getSdcNotification().getResources()) {
+ if ("VF".equals(resource.getResourceType())) {
+ for (IArtifactInfo artifact : resource.getArtifacts()) {
+ if ("DCAE_INVENTORY_BLUEPRINT".equals(artifact.getArtifactType())) {
+ blueprintArtifactName = artifact.getArtifactName();
+ blueprintInvariantResourceUuid = resource.getResourceInvariantUUID();
+ }
+ }
+ }
+ }
+ }
+
private void loadDcaeBlueprint() throws IOException, SdcArtifactInstallerException {
List<ZipEntry> listEntries = new ArrayList<>();
try (ZipFile zipFile = new ZipFile(csarFilePath)) {
@@ -136,4 +157,20 @@ public class CsarHandler {
public synchronized String getDcaeBlueprint() {
return dcaeBlueprint;
}
+
+ public INotificationData getSdcNotification() {
+ return sdcNotification;
+ }
+
+ public String getBlueprintArtifactName() {
+ return blueprintArtifactName;
+ }
+
+ public String getBlueprintInvariantResourceUuid() {
+ return blueprintInvariantResourceUuid;
+ }
+
+ public String getBlueprintInvariantServiceUuid() {
+ return blueprintInvariantServiceUuid;
+ }
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index c56eed517..3a6bef8d8 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -35,7 +35,8 @@ import java.util.Map;
import javax.annotation.PostConstruct;
-import org.onap.clamp.clds.config.ClampProperties;
+import org.json.simple.parser.ParseException;
+import org.onap.clamp.clds.client.DcaeInventoryServices;
import org.onap.clamp.clds.config.sdc.BlueprintParserFilesConfiguration;
import org.onap.clamp.clds.config.sdc.BlueprintParserMappingConfiguration;
import org.onap.clamp.clds.dao.CldsDao;
@@ -55,8 +56,8 @@ public class CsarInstallerImpl implements CsarInstaller {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(CsarInstallerImpl.class);
private Map<String, BlueprintParserFilesConfiguration> bpmnMapping = new HashMap<>();
- public static final String TEMPLATE_NAME_SUFFIX = "-template-dcae-designer";
- public static final String MODEL_NAME_SUFFIX = "-model-dcae-designer";
+ public static final String TEMPLATE_NAME_PREFIX = "DCAE-Designer-ClosedLoopTemplate-";
+ public static final String MODEL_NAME_PREFIX = "DCAE-Designer-ClosedLoopInstance-";
/**
* The file name that will be loaded by Spring.
*/
@@ -67,11 +68,11 @@ public class CsarInstallerImpl implements CsarInstaller {
@Autowired
private CldsDao cldsDao;
@Autowired
- private ClampProperties refProp;
- @Autowired
CldsTemplateService cldsTemplateService;
@Autowired
CldsService cldsService;
+ @Autowired
+ DcaeInventoryServices dcaeInventoryService;
@PostConstruct
public void loadConfiguration() throws IOException {
@@ -88,10 +89,15 @@ public class CsarInstallerImpl implements CsarInstaller {
@Override
public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException {
try {
- BlueprintParserFilesConfiguration configFiles = this.searchForRightMapping(csar);
- createFakeCldsModel(csar, configFiles, createFakeCldsTemplate(csar, configFiles));
+ String serviceTypeId = queryDcaeToGetServiceTypeId(csar);
+ String policyName = searchForPolicyName(csar);
+ if (policyName.contains("*")) {
+ }
+ createFakeCldsModel(csar, createFakeCldsTemplate(csar, this.searchForRightMapping(csar)), serviceTypeId);
} catch (IOException e) {
throw new SdcArtifactInstallerException("Exception caught during the Csar installation in database", e);
+ } catch (ParseException e) {
+ throw new SdcArtifactInstallerException("Exception caught during the Dcae query to get ServiceTypeId", e);
}
}
@@ -115,12 +121,38 @@ public class CsarInstallerImpl implements CsarInstaller {
return listConfig.get(0);
}
- private String createTemplateName(CsarHandler csar) {
- return csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + TEMPLATE_NAME_SUFFIX;
+ private String searchForPolicyName(CsarHandler csar) throws SdcArtifactInstallerException {
+ String policyName = null;
+ Yaml yaml = new Yaml();
+ List<String> policyNameList = new ArrayList<>();
+ Map<String, Object> templateNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
+ .load(csar.getDcaeBlueprint())).get("node_templates"));
+ templateNodes.entrySet().stream().filter(e -> e.getKey().contains("policy_")).forEach(ef -> {
+ String filteredPolicyName = (String) ((Map<String, Object>) ((Map<String, Object>) ef.getValue())
+ .get("properties")).get("policy_filter");
+ if (policyName != null) {
+ policyNameList.add(filteredPolicyName);
+ } else {
+ String inputPolicyName = (String) ((Map<String, Object>) ((Map<String, Object>) ((Map<String, Object>) ef
+ .getValue()).get("properties")).get("policy_id")).get("get_input");
+ if (inputPolicyName != null) {
+ policyNameList.add("get_input");
+ }
+ }
+ });
+ if (policyNameList.size() > 1) {
+ throw new SdcArtifactInstallerException(
+ "The code does not currently support multiple Policy MicroServices in the blueprint");
+ } else if (policyNameList.isEmpty()) {
+ throw new SdcArtifactInstallerException(
+ "There is no recognized Policy MicroService found in the blueprint");
+ }
+ return policyNameList.get(0);
}
- private String createModelName(CsarHandler csar) {
- return csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + MODEL_NAME_SUFFIX;
+ private String queryDcaeToGetServiceTypeId(CsarHandler csar) throws IOException, ParseException {
+ return dcaeInventoryService.getDcaeInformation(csar.getBlueprintArtifactName(),
+ csar.getBlueprintInvariantServiceUuid(), csar.getBlueprintInvariantResourceUuid());
}
private CldsTemplate createFakeCldsTemplate(CsarHandler csar, BlueprintParserFilesConfiguration configFiles)
@@ -129,19 +161,26 @@ public class CsarInstallerImpl implements CsarInstaller {
template.setBpmnId("Sdc-Generated");
template.setBpmnText(
IOUtils.toString(appContext.getResource(configFiles.getBpmnXmlFilePath()).getInputStream()));
- // ((ObjectNode)refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY));
template.setPropText(csar.getDcaeBlueprint());
template.setImageText(
IOUtils.toString(appContext.getResource(configFiles.getSvgXmlFilePath()).getInputStream()));
- return cldsTemplateService.putTemplate(createTemplateName(csar), template);
+ template.setName(TEMPLATE_NAME_PREFIX + csar.getSdcCsarHelper().getServiceMetadata().getValue("name"));
+ template.save(cldsDao, null);
+ return template;
}
- private CldsModel createFakeCldsModel(CsarHandler csar, BlueprintParserFilesConfiguration configFiles,
- CldsTemplate cldsTemplate) {
+ private CldsModel createFakeCldsModel(CsarHandler csar, CldsTemplate cldsTemplate, String serviceTypeId) {
CldsModel cldsModel = new CldsModel();
+ cldsModel.setControlNamePrefix(MODEL_NAME_PREFIX);
+ cldsModel.setName(csar.getSdcCsarHelper().getServiceMetadata().getValue("name"));
cldsModel.setBlueprintText(csar.getDcaeBlueprint());
cldsModel.setTemplateName(cldsTemplate.getName());
- // cldsModel.set
- return cldsService.putModel(createModelName(csar), cldsModel);
+ cldsModel.setTemplateId(cldsTemplate.getId());
+ cldsModel.setDocText(cldsTemplate.getPropText());
+ cldsModel.setPropText("{}");
+ cldsModel.setBpmnText(cldsTemplate.getBpmnText());
+ cldsModel.setTypeId(serviceTypeId);
+ cldsModel.save(cldsDao, null);
+ return cldsModel;
}
}
diff --git a/src/main/resources/clds/camel/flexible-flow.xml b/src/main/resources/clds/camel/flexible-flow.xml
index 7a3ebdb0a..b2a728d14 100644
--- a/src/main/resources/clds/camel/flexible-flow.xml
+++ b/src/main/resources/clds/camel/flexible-flow.xml
@@ -4,7 +4,6 @@
<choice>
<when>
<simple> ${exchangeProperty.actionCd} == 'SUBMIT' || ${exchangeProperty.actionCd} == 'RESUBMIT'</simple>
- <to uri="bean:org.onap.clamp.clds.client.SdcSendReqDelegate" />
<to uri="bean:org.onap.clamp.clds.client.TcaPolicyDelegate" />
<to uri="bean:org.onap.clamp.clds.client.HolmesPolicyDelegate" />
<to uri="bean:org.onap.clamp.clds.client.OperationalPolicyDelegate" />