import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
import com.google.gson.JsonObject;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import org.yaml.snakeyaml.Yaml;
/**
- * This class will be instantiated by spring config, and used by Sdc Controller. There is no state kept by the bean.
- * It's used to deploy the csar/notification received from SDC in DB.
+ * This class will be instantiated by spring config, and used by Sdc Controller.
+ * There is no state kept by the bean. It's used to deploy the csar/notification
+ * received from SDC in DB.
*/
public class CsarInstallerImpl implements CsarInstaller {
boolean alreadyInstalled = true;
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
alreadyInstalled = alreadyInstalled
- && (CldsModel.retrieve(cldsDao, buildModelName(csar, blueprint.getKey()), true).getId() != null) ? true
- : false;
+ && CldsModel.retrieve(cldsDao, buildModelName(csar, blueprint.getValue()), true).getId() != null;
}
return alreadyInstalled;
}
- public static String buildModelName(CsarHandler csar, String resourceInstanceName)
+ public static String buildModelName(CsarHandler csar, BlueprintArtifact artifact)
throws SdcArtifactInstallerException {
- String policyScopePrefix = searchForPolicyScopePrefix(csar.getMapOfBlueprints().get(resourceInstanceName));
+ String policyScopePrefix = searchForPolicyScopePrefix(artifact);
if (policyScopePrefix.contains("*")) {
// This is policy_filter type
policyScopePrefix = policyScopePrefix.replaceAll("\\*", "");
// This is normally the get_input case
policyScopePrefix = MODEL_NAME_PREFIX;
}
- return policyScopePrefix + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v"
- + csar.getSdcNotification().getServiceVersion().replace('.', '_') + "_"
- + resourceInstanceName.replaceAll(" ", "");
+ return (policyScopePrefix + "_" + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v"
+ + csar.getSdcNotification().getServiceVersion() + "_"
+ + artifact.getResourceAttached().getResourceInstanceName().replaceAll(" ", "") + "_"
+ + artifact.getBlueprintArtifactName().replace(".yaml", "")).replace('.', '_');
}
@Override
}
/**
- * This call must be done when deploying the SDC notification as this call get the latest version of the artifact
- * (version can be specified to DCAE call)
+ * This call must be done when deploying the SDC notification as this call get
+ * the latest version of the artifact (version can be specified to DCAE call)
*
* @return The DcaeInventoryResponse object containing the dcae values
*/
"{\"global\":[{\"name\":\"service\",\"value\":[\"" + blueprintArtifact.getDcaeBlueprint() + "\"]}]}");
template
.setImageText(IOUtils.toString(appContext.getResource(configFiles.getSvgXmlFilePath()).getInputStream()));
- template.setName(TEMPLATE_NAME_PREFIX
- + buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName()));
+ template.setName(TEMPLATE_NAME_PREFIX + buildModelName(csar, blueprintArtifact));
template.save(cldsDao, null);
logger.info("Fake Clds Template created for blueprint " + blueprintArtifact.getBlueprintArtifactName()
+ " with name " + template.getName());
private CldsModel createFakeCldsModel(CsarHandler csar, BlueprintArtifact blueprintArtifact,
CldsTemplate cldsTemplate, DcaeInventoryResponse dcaeInventoryResponse) throws SdcArtifactInstallerException {
-
+
if (dcaeInventoryResponse == null) {
throw new SdcArtifactInstallerException(
"DCAE inventory response is NULL, query to DCAE fail to be answered properly, this is required to deploy CSAR properly !!!");
}
try {
CldsModel cldsModel = new CldsModel();
- cldsModel.setName(buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName()));
+ cldsModel.setName(buildModelName(csar, blueprintArtifact));
cldsModel.setBlueprintText(blueprintArtifact.getDcaeBlueprint());
cldsModel.setTemplateName(cldsTemplate.getName());
cldsModel.setTemplateId(cldsTemplate.getId());