Creating SDNC Blueprints Content Generation Service to mash data into Velocity Templates
Change-Id: I0b5100f1dd242b9d70df7f919c2a7e4105364eed
Issue-ID: CCSDK-504
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator;\r
+\r
+public class ConfigGeneratorConstant {\r
+\r
+ private ConfigGeneratorConstant() {\r
+\r
+ }\r
+\r
+ public static final String STRING_ENCODING = "utf-8";\r
+ public static final String Y = "Y";\r
+ public static final String N = "N";\r
+ public static final String DATA_TYPE_TEXT = "TEXT";\r
+ public static final String DATA_TYPE_JSON = "JSON";\r
+ public static final String DATA_TYPE_XML = "XML";\r
+ public static final String DATA_TYPE_SQL = "SQL";\r
+\r
+ public static final String INPUT_PARAM_REQUEST_ID = "request-id";\r
+ public static final String INPUT_PARAM_RESOURCE_ID = "resource-id";\r
+ public static final String INPUT_PARAM_RESOURCE_TYPE = "resource-type";\r
+ public static final String INPUT_PARAM_ACTION_NAME = "action-name";\r
+ public static final String INPUT_PARAM_TEMPLATE_NAME = "template-name";\r
+ public static final String INPUT_PARAM_TEMPLATE_CONTENT = "template-content";\r
+ public static final String INPUT_PARAM_TEMPLATE_DATA = "template-data";\r
+\r
+ public static final String OUTPUT_PARAM_GENERATED_CONFIG = "generated-config";\r
+ public static final String OUTPUT_PARAM_MASK_INFO = "mask-info";\r
+ public static final String OUTPUT_PARAM_STATUS = "status";\r
+ public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";\r
+ public static final String OUTPUT_STATUS_SUCCESS = "success";\r
+ public static final String OUTPUT_STATUS_FAILURE = "failure";\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.data;\r
+\r
+public class ConfigGeneratorInfo {\r
+\r
+ private String requestId;\r
+ private String resourceId;\r
+ private String resourceType;\r
+ private String templateName;\r
+ private String recipeName;\r
+ private String resourceData;\r
+ private String templateContent;\r
+ private String mashedData;\r
+\r
+ public String getRequestId() {\r
+ return requestId;\r
+ }\r
+\r
+ public void setRequestId(String requestId) {\r
+ this.requestId = requestId;\r
+ }\r
+\r
+ public String getResourceId() {\r
+ return resourceId;\r
+ }\r
+\r
+ public void setResourceId(String resourceId) {\r
+ this.resourceId = resourceId;\r
+ }\r
+\r
+ public String getResourceType() {\r
+ return resourceType;\r
+ }\r
+\r
+ public void setResourceType(String resourceType) {\r
+ this.resourceType = resourceType;\r
+ }\r
+\r
+ public String getTemplateName() {\r
+ return templateName;\r
+ }\r
+\r
+ public void setTemplateName(String templateName) {\r
+ this.templateName = templateName;\r
+ }\r
+\r
+ public String getRecipeName() {\r
+ return recipeName;\r
+ }\r
+\r
+ public void setRecipeName(String recipeName) {\r
+ this.recipeName = recipeName;\r
+ }\r
+\r
+ public String getResourceData() {\r
+ return resourceData;\r
+ }\r
+\r
+ public void setResourceData(String resourceData) {\r
+ this.resourceData = resourceData;\r
+ }\r
+\r
+ public String getTemplateContent() {\r
+ return templateContent;\r
+ }\r
+\r
+ public void setTemplateContent(String templateContent) {\r
+ this.templateContent = templateContent;\r
+ }\r
+\r
+ public String getMashedData() {\r
+ return mashedData;\r
+ }\r
+\r
+ public void setMashedData(String mashedData) {\r
+ this.mashedData = mashedData;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "ConfigGeneratorInfo [requestId=" + requestId + ", resourceId=" + resourceId + ", resourceType="\r
+ + resourceType + ", templateName=" + templateName + ", recipeName=" + recipeName + ", resourceData="\r
+ + resourceData + ", templateContent=" + templateContent + ", mashedData=" + mashedData + "]";\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.service;\r
+\r
+import java.util.Map;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService;\r
+import org.onap.ccsdk.config.generator.ConfigGeneratorConstant;\r
+import org.onap.ccsdk.config.generator.data.ConfigGeneratorInfo;\r
+import org.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.service.ComponentNode;\r
+import org.onap.ccsdk.config.model.service.ConfigModelService;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+public class ConfigGeneratorNode implements ComponentNode {\r
+\r
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNode.class);\r
+\r
+ private ConfigModelService configModelService;\r
+ private ConfigResourceService configResourceService;\r
+ private ConfigGeneratorService configGeneratorService;\r
+\r
+ public ConfigGeneratorNode(ConfigResourceService configResourceService, ConfigModelService configModelService) {\r
+ this.configResourceService = configResourceService;\r
+ this.configModelService = configModelService;\r
+ this.configGeneratorService = new ConfigGeneratorServiceImpl(this.configResourceService);\r
+ }\r
+\r
+ @Override\r
+ public Boolean preCondition(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ logger.trace("Received generateConfiguration preCondition call with params : ({})", inParams);\r
+ return Boolean.TRUE;\r
+ }\r
+\r
+ @Override\r
+ public void preProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ logger.trace("Received generateConfiguration preProcess call with params : ({})", inParams);\r
+ }\r
+\r
+ @Override\r
+ public void process(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {\r
+ logger.trace("Received generateConfiguration process call with params : ({})", inParams);\r
+ }\r
+\r
+ @SuppressWarnings("squid:S3776")\r
+ @Override\r
+ public void process(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ logger.trace("Received generateConfiguration process with params : ({})", inParams);\r
+ String prifix = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR);\r
+ try {\r
+ prifix = StringUtils.isNotBlank(prifix) ? (prifix + ".") : "";\r
+\r
+ String templateContent = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT);\r
+ String templateData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA);\r
+ String requestId = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_ID);\r
+ String resourceId = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESOURCE_ID);\r
+ String resourceType = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESOURCE_TYPE);\r
+ String recipeName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_ACTION_NAME);\r
+ String templateName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_NAME);\r
+\r
+ ConfigGeneratorInfo configGeneratorInfo = null;\r
+ if (StringUtils.isNotBlank(templateContent) && StringUtils.isNotBlank(templateData)) {\r
+ configGeneratorInfo = this.configGeneratorService.generateConfiguration(templateContent, templateData);\r
+ } else {\r
+ if (StringUtils.isBlank(requestId)) {\r
+ throw new SvcLogicException("Config Generator Request Id is missing.");\r
+ }\r
+ if (StringUtils.isBlank(resourceId)) {\r
+ throw new SvcLogicException("Config Generator Resource Id is missing.");\r
+ }\r
+ if (StringUtils.isBlank(resourceType)) {\r
+ throw new SvcLogicException("Config Generator Resource Type is missing.");\r
+ }\r
+ if (StringUtils.isBlank(recipeName)) {\r
+ throw new SvcLogicException("Config Generator Action Name is missing.");\r
+ }\r
+ if (StringUtils.isBlank(templateName)) {\r
+ throw new SvcLogicException("Config Generator Template Name Id is missing.");\r
+ }\r
+\r
+ templateContent = configModelService.getNodeTemplateContent(ctx, templateName);\r
+\r
+ if (StringUtils.isBlank(templateContent)) {\r
+ throw new SvcLogicException(\r
+ "Failed to get the Template Content for the Temaple Name :" + templateName);\r
+ }\r
+\r
+ configGeneratorInfo = new ConfigGeneratorInfo();\r
+ configGeneratorInfo.setRequestId(requestId);\r
+ configGeneratorInfo.setResourceId(resourceId);\r
+ configGeneratorInfo.setResourceType(resourceType);\r
+ configGeneratorInfo.setRecipeName(recipeName);\r
+ configGeneratorInfo.setTemplateName(templateName);\r
+ configGeneratorInfo.setTemplateContent(templateContent);\r
+\r
+ this.configGeneratorService.generateConfiguration(configGeneratorInfo);\r
+ }\r
+ if (configGeneratorInfo != null) {\r
+ ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG,\r
+ configGeneratorInfo.getMashedData());\r
+ }\r
+ ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS,\r
+ ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS);\r
+ } catch (Exception e) {\r
+ ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS,\r
+ ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE);\r
+ ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());\r
+ logger.error("Failed in generateConfiguration ({})", e);\r
+ throw new SvcLogicException(e.getMessage());\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void postProcess(Map<String, String> inParams, SvcLogicContext ctx, Map<String, Object> componentContext)\r
+ throws SvcLogicException {\r
+ logger.info("Received generateConfiguration postProcess with params : ({})", inParams);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.service;\r
+\r
+import org.onap.ccsdk.config.generator.data.ConfigGeneratorInfo;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+\r
+public interface ConfigGeneratorService {\r
+\r
+ public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData)\r
+ throws SvcLogicException;\r
+\r
+ public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData, boolean ignoreNull)\r
+ throws SvcLogicException;\r
+\r
+ public ConfigGeneratorInfo generateConfiguration(ConfigGeneratorInfo configGeneratorInfo) throws SvcLogicException;\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.service;\r
+\r
+import java.io.StringWriter;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import org.apache.commons.collections.CollectionUtils;\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.apache.velocity.VelocityContext;\r
+import org.apache.velocity.app.Velocity;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
+import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService;\r
+import org.onap.ccsdk.config.generator.data.ConfigGeneratorInfo;\r
+import org.onap.ccsdk.config.generator.tool.CustomJsonNodeFactory;\r
+import org.onap.ccsdk.config.model.utils.TransformationUtils;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+public class ConfigGeneratorServiceImpl implements ConfigGeneratorService {\r
+\r
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorServiceImpl.class);\r
+ private static final String CLASS_NAME = "ConfigGeneratorServiceImpl";\r
+\r
+ private ConfigResourceService configResourceService;\r
+\r
+ public ConfigGeneratorServiceImpl(ConfigResourceService configResourceService) {\r
+ logger.info("{} Constuctor Initated...", CLASS_NAME);\r
+ this.configResourceService = configResourceService;\r
+ }\r
+\r
+ @Override\r
+ public ConfigGeneratorInfo generateConfiguration(ConfigGeneratorInfo configGeneratorInfo) throws SvcLogicException {\r
+\r
+ if (configGeneratorInfo != null && StringUtils.isNotBlank(configGeneratorInfo.getResourceId())\r
+ && StringUtils.isNotBlank(configGeneratorInfo.getResourceType())\r
+ && StringUtils.isNotBlank(configGeneratorInfo.getRecipeName())\r
+ && StringUtils.isNotBlank(configGeneratorInfo.getTemplateName())\r
+ && StringUtils.isNotBlank(configGeneratorInfo.getTemplateContent())) {\r
+\r
+ ConfigResource configResourceQuery = new ConfigResource();\r
+ configResourceQuery.setResourceId(configGeneratorInfo.getResourceId());\r
+ configResourceQuery.setResourceType(configGeneratorInfo.getResourceType());\r
+ configResourceQuery.setTemplateName(configGeneratorInfo.getTemplateName());\r
+\r
+ List<ConfigResource> configResourceList = configResourceService.getConfigResource(configResourceQuery);\r
+\r
+ if (CollectionUtils.isEmpty(configResourceList)) {\r
+ throw new SvcLogicException("No Config Resource found");\r
+ } else if (configResourceList.size() > 1) {\r
+ throw new SvcLogicException("More than one Config Resource found for specified parameter for"\r
+ + " resourceId " + configGeneratorInfo.getResourceId() + ", resourceType "\r
+ + configGeneratorInfo.getResourceType() + ", recipeName " + configGeneratorInfo.getRecipeName()\r
+ + ", templateName " + configGeneratorInfo.getTemplateName());\r
+ }\r
+\r
+ ConfigResource configResource = configResourceList.get(0);\r
+\r
+ if (configResource != null && StringUtils.isNotBlank(configResource.getResourceData())) {\r
+ configGeneratorInfo.setResourceData(configResource.getResourceData());\r
+ logger.debug("Retrieve ConfigResource Data : ({})", configResource.getResourceData());\r
+ ConfigGeneratorInfo generatorInfo = generateConfiguration(configGeneratorInfo.getTemplateContent(),\r
+ configResource.getResourceData());\r
+ if (generatorInfo != null) {\r
+ configGeneratorInfo.setMashedData(generatorInfo.getMashedData());\r
+ }\r
+ } else {\r
+ throw new SvcLogicException(\r
+ "Failed to get the Resource Data for the Resource Id :" + configGeneratorInfo.getResourceId()\r
+ + " of template :" + configGeneratorInfo.getTemplateName());\r
+ }\r
+ }\r
+ return configGeneratorInfo;\r
+ }\r
+\r
+ @Override\r
+ public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData)\r
+ throws SvcLogicException {\r
+ return generateConfiguration(templateContent, templateData, true);\r
+ }\r
+\r
+ @Override\r
+ public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData, boolean ignoreNull)\r
+ throws SvcLogicException {\r
+ ConfigGeneratorInfo configGeneratorInfo = null;\r
+ try {\r
+ if (StringUtils.isNotBlank(templateContent) && StringUtils.isNotBlank(templateData)) {\r
+ configGeneratorInfo = new ConfigGeneratorInfo();\r
+\r
+ Velocity.init();\r
+\r
+ ObjectMapper mapper = new ObjectMapper();\r
+ CustomJsonNodeFactory f = new CustomJsonNodeFactory();\r
+ mapper.setNodeFactory(f);\r
+\r
+ JsonNode jsonObj = mapper.readValue(templateData, JsonNode.class);\r
+ if (ignoreNull) {\r
+ TransformationUtils.removeJsonNullNode(jsonObj);\r
+ }\r
+\r
+ VelocityContext context = new VelocityContext();\r
+ context.put("StringUtils", org.apache.commons.lang3.StringUtils.class);\r
+ context.put("BooleanUtils", org.apache.commons.lang3.BooleanUtils.class);\r
+\r
+ Iterator<String> ii = jsonObj.fieldNames();\r
+ while (ii.hasNext()) {\r
+ String key = ii.next();\r
+ JsonNode node = jsonObj.get(key);\r
+ logger.info("Adding key ({}) with value ({})", key, node);\r
+ context.put(key, node);\r
+ }\r
+\r
+ StringWriter writer = new StringWriter();\r
+ Velocity.evaluate(context, writer, "TemplateData", templateContent);\r
+ writer.flush();\r
+ configGeneratorInfo.setMashedData(writer.toString());\r
+ }\r
+ } catch (Exception e) {\r
+ logger.error("Failed to generate Configuration ({})", e.getMessage());\r
+ throw new SvcLogicException(e.getMessage(), e);\r
+ }\r
+ return configGeneratorInfo;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.tool;\r
+\r
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;\r
+import com.fasterxml.jackson.databind.node.TextNode;\r
+\r
+public class CustomJsonNodeFactory extends JsonNodeFactory {\r
+\r
+ @Override\r
+ public TextNode textNode(String text) {\r
+ return new CustomTextNode(text);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.tool;\r
+\r
+import com.fasterxml.jackson.core.io.CharTypes;\r
+import com.fasterxml.jackson.databind.node.TextNode;\r
+\r
+public class CustomTextNode extends TextNode {\r
+\r
+ public CustomTextNode(String v) {\r
+ super(v);\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ int len = textValue().length();\r
+ len = len + 2 + (len >> 4);\r
+ StringBuilder sb = new StringBuilder(len);\r
+ appendQuoted(sb, textValue());\r
+ return sb.toString();\r
+ }\r
+\r
+ protected static void appendQuoted(StringBuilder sb, String content) {\r
+ CharTypes.appendQuoted(sb, content);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.tool;\r
+\r
+import org.apache.commons.lang3.StringUtils;\r
+\r
+@SuppressWarnings("squid:S1118")\r
+public class EscapeUtils {\r
+\r
+ public static String escapeSql(String str) {\r
+ if (str == null) {\r
+ return null;\r
+ }\r
+ String[] searchList = new String[] {"'", "\\"};\r
+ String[] replacementList = new String[] {"''", "\\\\"};\r
+ return StringUtils.replaceEach(str, searchList, replacementList);\r
+ }\r
+\r
+ // For Generic Purpose\r
+ public static String escapeSequence(String s) {\r
+ if (s == null) {\r
+ return null;\r
+ }\r
+\r
+ int length = s.length();\r
+ int newLength = length;\r
+ for (int i = 0; i < length; i++) {\r
+ char c = s.charAt(i);\r
+ switch (c) {\r
+ case '\\':\r
+ case '\"':\r
+ case '\'':\r
+ case '\0':\r
+ newLength += 1;\r
+ break;\r
+ default:\r
+ // do nothing\r
+ }\r
+ }\r
+ if (length == newLength) {\r
+ // nothing to escape in the string\r
+ return s;\r
+ }\r
+ StringBuilder sb = new StringBuilder(newLength);\r
+ for (int i = 0; i < length; i++) {\r
+ char c = s.charAt(i);\r
+ switch (c) {\r
+ case '\\':\r
+ sb.append("\\\\");\r
+ break;\r
+ case '\"':\r
+ sb.append("\\\"");\r
+ break;\r
+ case '\'':\r
+ sb.append("\\\'");\r
+ break;\r
+ case '\0':\r
+ sb.append("\\0");\r
+ break;\r
+ default:\r
+ sb.append(c);\r
+ }\r
+ }\r
+ return sb.toString();\r
+ }\r
+\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+ Copyright © 2017-2018 AT&T Intellectual Property.\r
+ Modifications Copyright © 2018 IBM.\r
+ \r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+ \r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+ \r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+-->\r
+\r
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"\r
+ odl:use-default-for-reference-types="true">\r
+\r
+ <reference id="configModelService"\r
+ interface="org.onap.ccsdk.config.model.service.ConfigModelService" />\r
+\r
+ <reference id="configResourceService"\r
+ interface="org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService" />\r
+\r
+ <!-- Expose the Common Component Bean -->\r
+\r
+ <bean id="configGeneratorService"\r
+ class="org.onap.ccsdk.config.generator.service.ConfigGeneratorServiceImpl">\r
+ <argument ref="configResourceService" />\r
+ </bean>\r
+\r
+ <service ref="configGeneratorService"\r
+ interface="org.onap.ccsdk.config.generator.service.ConfigGeneratorService" />\r
+\r
+ <bean id="configGeneratorNode"\r
+ class="org.onap.ccsdk.config.generator.service.ConfigGeneratorNode">\r
+ <argument ref="configResourceService" />\r
+ <argument ref="configModelService" />\r
+ </bean>\r
+\r
+ <service ref="configGeneratorNode"\r
+ interface="org.onap.ccsdk.config.generator.service.ConfigGeneratorNode" />\r
+\r
+\r
+</blueprint>\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.service;\r
+\r
+import static org.mockito.Matchers.any;\r
+import java.nio.charset.Charset;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import org.apache.commons.io.IOUtils;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.MockitoAnnotations;\r
+import org.mockito.invocation.InvocationOnMock;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.mockito.stubbing.Answer;\r
+import org.onap.ccsdk.config.data.adaptor.domain.ConfigResource;\r
+import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;\r
+import org.onap.ccsdk.config.data.adaptor.service.ConfigResourceService;\r
+import org.onap.ccsdk.config.generator.ConfigGeneratorConstant;\r
+import org.onap.ccsdk.config.model.ConfigModelConstant;\r
+import org.onap.ccsdk.config.model.service.ConfigModelService;\r
+import org.onap.ccsdk.config.model.service.ConfigModelServiceImpl;\r
+import org.onap.ccsdk.config.model.utils.TransformationUtils;\r
+import org.onap.ccsdk.config.rest.adaptor.service.ConfigRestAdaptorService;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+\r
+@RunWith(MockitoJUnitRunner.class)\r
+public class ConfigGeneratorNodeTest {\r
+\r
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNodeTest.class);\r
+\r
+ @Mock\r
+ private ConfigResourceService configResourceService;\r
+\r
+ @Mock\r
+ private ConfigRestAdaptorService configRestAdaptorService;\r
+\r
+ private ConfigModelService configModelService;\r
+\r
+ @Before\r
+ public void setUp() throws Exception {\r
+\r
+ configModelService = new ConfigModelServiceImpl(configRestAdaptorService);\r
+\r
+ MockitoAnnotations.initMocks(this);\r
+\r
+ try {\r
+ Mockito.doAnswer(new Answer<Void>() {\r
+ @Override\r
+ public Void answer(InvocationOnMock invocationOnMock) throws Throwable {\r
+ Object[] args = invocationOnMock.getArguments();\r
+ if (args != null) {\r
+ logger.trace("Transaction info " + Arrays.asList(args));\r
+ }\r
+ return null;\r
+ }\r
+ }).when(configResourceService).save(any(TransactionLog.class));\r
+\r
+ Mockito.doAnswer(new Answer<List<ConfigResource>>() {\r
+ @Override\r
+ public List<ConfigResource> answer(InvocationOnMock invocationOnMock) throws Throwable {\r
+ List<ConfigResource> configResources = new ArrayList<>();\r
+ Object[] args = invocationOnMock.getArguments();\r
+ if (args != null) {\r
+ logger.trace("Transaction info " + Arrays.asList(args));\r
+ String resourceData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
+ .getResourceAsStream("service_templates/configdata.json"), Charset.defaultCharset());\r
+ ConfigResource configResource = (ConfigResource) args[0];\r
+ configResource.setRecipeName("Sample-recipe");\r
+ configResource.setResourceData(resourceData);\r
+ configResources.add(configResource);\r
+ }\r
+ return configResources;\r
+ }\r
+ }).when(configResourceService).getConfigResource(any(ConfigResource.class));\r
+\r
+ } catch (SvcLogicException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testInputTemplateContentNData() throws Exception {\r
+\r
+ ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService);\r
+\r
+ Map<String, String> inParams = new HashMap<String, String>();\r
+ inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
+\r
+ String jsonData = IOUtils.toString(\r
+ ConfigGeneratorNodeTest.class.getClassLoader().getResourceAsStream("service_templates/configdata.json"),\r
+ Charset.defaultCharset());\r
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData);\r
+\r
+ String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
+ .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset());\r
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData);\r
+\r
+ SvcLogicContext ctx = new SvcLogicContext();\r
+ Map<String, Object> componentContext = new HashMap<>();\r
+ configGeneratorNode.process(inParams, ctx, componentContext);\r
+ Assert.assertEquals("Failed to generate Configuration Status as Failure",\r
+ ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,\r
+ ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));\r
+ Assert.assertNotNull("Failed to generate Configuration",\r
+ ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
+\r
+ logger.trace("Generated Configuration:\n "\r
+ + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
+ logger.trace("Generated Configuration:\n "\r
+ + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testInputTemplateWithNullData() throws Exception {\r
+\r
+ ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService);\r
+\r
+ Map<String, String> inParams = new HashMap<String, String>();\r
+ inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test");\r
+\r
+ String jsonData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
+ .getResourceAsStream("service_templates/configdata_with_null.json"), Charset.defaultCharset());\r
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData);\r
+\r
+ String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
+ .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset());\r
+ inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData);\r
+\r
+ SvcLogicContext ctx = new SvcLogicContext();\r
+ Map<String, Object> componentContext = new HashMap<>();\r
+ configGeneratorNode.process(inParams, ctx, componentContext);\r
+ Assert.assertEquals("Failed to generate Configuration Status as Failure",\r
+ ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,\r
+ ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));\r
+ Assert.assertNotNull("Failed to generate Configuration",\r
+ ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
+\r
+ logger.trace("Generated Configuration:\n "\r
+ + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
+ logger.trace("Generated Configuration:\n "\r
+ + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO));\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testDBTemplateContentNData() throws Exception {\r
+\r
+ String fileContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
+ .getResourceAsStream("service_templates/generate_configuration.json"), Charset.defaultCharset());\r
+\r
+ String baseConfigTemplateContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader()\r
+ .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset());\r
+\r
+ Map<String, String> context = new HashMap<>();\r
+ context = configModelService.convertServiceTemplate2Properties(fileContent, context);\r
+\r
+ context.put("node_templates.base-config-template.content", baseConfigTemplateContent);\r
+\r
+ Assert.assertNotNull("Failed to Prepare Context : ", context);\r
+\r
+ context.put("request-id", "12345");\r
+ context.put("vnf-id", "vnf12345");\r
+ context.put("action-name", "config-generator-action");\r
+\r
+ Map<String, String> inparams = new HashMap<String, String>();\r
+ inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration");\r
+\r
+ SvcLogicContext inputContext = new SvcLogicContext();\r
+ context.forEach((name, value) -> {\r
+ inputContext.setAttribute(name, value);\r
+ });\r
+\r
+ TransformationUtils.printMap(context);\r
+ configModelService.assignInParamsFromModel(inputContext, inparams);\r
+ ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService);\r
+\r
+ Map<String, Object> componentContext = new HashMap<>();\r
+ configGeneratorNode.process(inparams, inputContext, componentContext);\r
+\r
+ Assert.assertEquals("Failed to generate Configuration Status as Failure",\r
+ ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS,\r
+ inputContext.getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS));\r
+ Assert.assertNotNull("Failed to generate Configuration", inputContext\r
+ .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
+\r
+ logger.trace("Generated Configuration:\n " + inputContext\r
+ .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG));\r
+ }\r
+\r
+ @Test\r
+ public void testTemplateContentNDataForMask() throws Exception {\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.config.generator.tool;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+public class EscapeUtilsTest {\r
+\r
+ @Test\r
+ public void testEscapeSql() {\r
+ Assert.assertEquals("", EscapeUtils.escapeSql(""));\r
+ Assert.assertEquals("text", EscapeUtils.escapeSql("text"));\r
+\r
+ Assert.assertEquals("''", EscapeUtils.escapeSql("'"));\r
+ Assert.assertEquals("\\\\", EscapeUtils.escapeSql("\\"));\r
+\r
+ Assert.assertEquals("text''text", EscapeUtils.escapeSql("text'text"));\r
+ Assert.assertEquals("text\\\\text", EscapeUtils.escapeSql("text\\text"));\r
+ }\r
+\r
+ @Test\r
+ public void testEscapeSequence() {\r
+ Assert.assertEquals("", EscapeUtils.escapeSequence(""));\r
+ Assert.assertEquals("text", EscapeUtils.escapeSequence("text"));\r
+\r
+ Assert.assertEquals("\\\'", EscapeUtils.escapeSequence("'"));\r
+ Assert.assertEquals("\\\"", EscapeUtils.escapeSequence("\""));\r
+ Assert.assertEquals("\\\\", EscapeUtils.escapeSequence("\\"));\r
+\r
+ Assert.assertEquals("text\\\'text", EscapeUtils.escapeSequence("text'text"));\r
+ Assert.assertEquals("text\\\"text", EscapeUtils.escapeSequence("text\"text"));\r
+ Assert.assertEquals("text\\\\text", EscapeUtils.escapeSequence("text\\text"));\r
+ }\r
+\r
+}\r
--- /dev/null
+{\r
+ "node0_hostname": "appc-host",\r
+ "node0_backup_router_address": "2001:2001:2001:2001:2001:2001:2001:2001",\r
+ "servers": [\r
+ "Server1",\r
+ "Server2",\r
+ "Server3"\r
+ ],\r
+ "tacplus-servers": [\r
+ {\r
+ "tacplus-server-name": "tacplus-server-name1",\r
+ "tacplus-server-source-address": "enc-dsdsasa1"\r
+ },\r
+ {\r
+ "tacplus-server-name": "tacplus-server-name2",\r
+ "tacplus-server-source-address": "enc-dsdsasa2"\r
+ }\r
+ ],\r
+ "classes": [\r
+ {\r
+ "name": "superuser-class",\r
+ "idle-timeout": 5,\r
+ "permissions": "all"\r
+ },\r
+ {\r
+ "name": "tacacs-adv-class",\r
+ "idle-timeout": 5\r
+ },\r
+ {\r
+ "name": "tacacs-base-class",\r
+ "idle-timeout": 5\r
+ }\r
+ ],\r
+ "system-password": "teamops-system-password",\r
+ "root-password": "teamops-root-password"\r
+}\r
--- /dev/null
+{\r
+ "node0_hostname": null,\r
+ "node0_backup_router_address": "2001:2001:2001:2001:2001:2001:2001:2001",\r
+ "servers": [\r
+ "Server1",\r
+ "Server2",\r
+ "Server3"\r
+ ],\r
+ "tacplus-servers": [\r
+ {\r
+ "tacplus-server-name": null,\r
+ "tacplus-server-source-address": "enc-dsdsasa1"\r
+ },\r
+ {\r
+ "tacplus-server-name": "tacplus-server-name2",\r
+ "tacplus-server-source-address": "enc-dsdsasa2"\r
+ }\r
+ ],\r
+ "classes": [\r
+ {\r
+ "name": "superuser-class",\r
+ "idle-timeout": 5,\r
+ "permissions": "all"\r
+ },\r
+ {\r
+ "name": "tacacs-adv-class",\r
+ "idle-timeout": 5\r
+ },\r
+ {\r
+ "name": "tacacs-base-class",\r
+ "idle-timeout": 5\r
+ }\r
+ ],\r
+ "system-password": "teamops-system-password",\r
+ "root-password": "teamops-root-password"\r
+}
\ No newline at end of file
--- /dev/null
+{\r
+ "metadata": {\r
+ "author": "ks220y@att.com",\r
+ "service-template-name": "VRR-baseconfiguration",\r
+ "service-template-version": "1.0.0",\r
+ "service-type": "AVPN",\r
+ "vnf-type": "VRR",\r
+ "action": "Base Configuration",\r
+ "sub-action": "Generate Configuration"\r
+ },\r
+ "topology_template": {\r
+ "inputs": {\r
+ "request-id": {\r
+ "required": true,\r
+ "type": "string"\r
+ },\r
+ "service-instance-id": {\r
+ "required": true,\r
+ "type": "string"\r
+ },\r
+ "vnf-id": {\r
+ "required": true,\r
+ "type": "string"\r
+ }\r
+ },\r
+ "node_templates": {\r
+ "base-config-template": {\r
+ "type": "artifact-config-template",\r
+ "properties": {\r
+ "action-names": [\r
+ "resource-assignment-action"\r
+ ]\r
+ },\r
+ "capabilities": {\r
+ "content": {\r
+ "properties": {\r
+ "content": "db://base-config-template"\r
+ }\r
+ },\r
+ "mapping": {\r
+ "properties": {\r
+ "mapping": [\r
+ {\r
+ "name": "bundle-id",\r
+ "input-param": true,\r
+ "property": {\r
+ "type": "string",\r
+ "required": true\r
+ },\r
+ "dictionary-name": "bundle-id",\r
+ "dictionary-source": "mdsal"\r
+ },\r
+ {\r
+ "name": "bundle-mac",\r
+ "input-param": true,\r
+ "property": {\r
+ "type": "string"\r
+ },\r
+ "dictionary-name": "bundle-mac",\r
+ "dictionary-source": "db"\r
+ }\r
+ ]\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "generate-configuration": {\r
+ "type": "component-config-generator",\r
+ "interfaces": {\r
+ "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": {\r
+ "operations": {\r
+ "process": {\r
+ "inputs": {\r
+ "resource-type": "vnf-type",\r
+ "request-id": "{ \"get_attribute\" : \"request-id\" }",\r
+ "resource-id": "{ \"get_input\" : \"vnf-id\" }",\r
+ "action-name": "{ \"get_attribute\" : \"action-name\" }",\r
+ "template-name": "base-config-template"\r
+ },\r
+ "outputs": {\r
+ "generated-config": "",\r
+ "status": ""\r
+ }\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "capabilities": {\r
+ "component-node": {\r
+ \r
+ }\r
+ }\r
+ },\r
+ "config-generator-action": {\r
+ "type": "dg-config-generator",\r
+ "interfaces": {\r
+ "CONFIG": {\r
+ "operations": {\r
+ "GenerateConfiguration": {\r
+ \r
+ }\r
+ }\r
+ }\r
+ },\r
+ "capabilities": {\r
+ "dg-node": {\r
+ \r
+ }\r
+ },\r
+ "requirements": {\r
+ "component-dependency": {\r
+ "capability": "component-node",\r
+ "node": "generate-configuration",\r
+ "relationship": "tosca.relationships.DependsOn"\r
+ }\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "node_types": {\r
+ "artifact-config-template": {\r
+ "description": "This is Configuration Velocity Template",\r
+ "version": "1.0.0",\r
+ "properties": {\r
+ "action-names": {\r
+ "required": true,\r
+ "type": "list",\r
+ "entry_schema": {\r
+ "type": "string"\r
+ }\r
+ }\r
+ },\r
+ "capabilities": {\r
+ "content": {\r
+ "type": "tosca.capability.Content",\r
+ "properties": {\r
+ "content": {\r
+ "required": true,\r
+ "type": "string"\r
+ }\r
+ }\r
+ },\r
+ "mapping": {\r
+ "type": "tosca.capability.Mapping",\r
+ "properties": {\r
+ "mapping": {\r
+ "required": false,\r
+ "type": "list",\r
+ "entry_schema": {\r
+ "type": "datatype-resource-assignment"\r
+ }\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "derived_from": "tosca.nodes.Artifact"\r
+ },\r
+ "component-config-generator": {\r
+ "description": "This is Generate Configuration Component API",\r
+ "version": "1.0.0",\r
+ "capabilities": {\r
+ "component-node": {\r
+ "type": "tosca.capabilities.Node"\r
+ }\r
+ },\r
+ "interfaces": {\r
+ "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": {\r
+ "operations": {\r
+ "process": {\r
+ "inputs": {\r
+ "template-data": {\r
+ "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present",\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "template-content": {\r
+ "description": "Conditional : Dynamic Template used to generate Configuration.",\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "resource-type": {\r
+ "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "request-id": {\r
+ "description": "Request Id used to store the generated configuration, in the database along with the template-name",\r
+ "required": true,\r
+ "type": "string"\r
+ },\r
+ "resource-id": {\r
+ "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present",\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "action-name": {\r
+ "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "template-name": {\r
+ "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.",\r
+ "required": true,\r
+ "type": "string"\r
+ }\r
+ },\r
+ "outputs": {\r
+ "generated-config": {\r
+ "description": "Generated Configuration for the Template adn Resource Data",\r
+ "required": true,\r
+ "type": "string"\r
+ },\r
+ "mask-info": {\r
+ "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.config.model.data.custom.MaskInfo ",\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "status": {\r
+ "description": "Status of the Component Execution ( success or failure )",\r
+ "required": true,\r
+ "type": "string"\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "derived_from": "tosca.nodes.Component"\r
+ },\r
+ "dg-config-generator": {\r
+ "description": "This is Activate DG for Config Generator Directed Graph",\r
+ "version": "1.0.0",\r
+ "properties": {\r
+ "mode": {\r
+ "required": false,\r
+ "type": "string",\r
+ "default": "sync"\r
+ },\r
+ "version": {\r
+ "required": false,\r
+ "type": "string",\r
+ "default": "LATEST"\r
+ },\r
+ "is-start-flow": {\r
+ "required": false,\r
+ "type": "boolean",\r
+ "default": "false"\r
+ }\r
+ },\r
+ "capabilities": {\r
+ "dg-node": {\r
+ "type": "tosca.capabilities.Node"\r
+ },\r
+ "content": {\r
+ "type": "tosca.capability.Content",\r
+ "properties": {\r
+ "type": {\r
+ "required": false,\r
+ "type": "string",\r
+ "default": "json"\r
+ },\r
+ "content": {\r
+ "required": true,\r
+ "type": "string"\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "requirements": {\r
+ "component-dependency": {\r
+ "capability": "component-node",\r
+ "node": "component-config-generator",\r
+ "relationship": "tosca.relationships.DependsOn"\r
+ }\r
+ },\r
+ "interfaces": {\r
+ "CONFIG": {\r
+ "operations": {\r
+ "GenerateConfiguration": {\r
+ "inputs": {\r
+ "params": {\r
+ "required": false,\r
+ "type": "list",\r
+ "entry_schema": {\r
+ "type": "datatype-property"\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ },\r
+ "derived_from": "tosca.nodes.DG"\r
+ }\r
+ },\r
+ "data_types": {\r
+ "datatype-resource-assignment": {\r
+ "version": "1.0.0",\r
+ "description": "This is Resource Assignment Data Type",\r
+ "properties": {\r
+ "property": {\r
+ "required": true,\r
+ "type": "datatype-property"\r
+ },\r
+ "input-param": {\r
+ "required": true,\r
+ "type": "boolean"\r
+ },\r
+ "dictionary-name": {\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "dictionary-source": {\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "dependencies": {\r
+ "required": true,\r
+ "type": "list",\r
+ "entry_schema": {\r
+ "type": "string"\r
+ }\r
+ }\r
+ },\r
+ "derived_from": "tosca.datatypes.Root"\r
+ },\r
+ "datatype-property": {\r
+ "version": "1.0.0",\r
+ "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",\r
+ "properties": {\r
+ "type": {\r
+ "required": true,\r
+ "type": "string"\r
+ },\r
+ "description": {\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "required": {\r
+ "required": false,\r
+ "type": "boolean"\r
+ },\r
+ "default": {\r
+ "required": false,\r
+ "type": "string"\r
+ },\r
+ "entry_schema": {\r
+ "required": false,\r
+ "type": "string"\r
+ }\r
+ },\r
+ "derived_from": "tosca.datatypes.Root"\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"\r
+xmlns:a="http://xml.juniper.net/junos/15.1X49/junos">\r
+ <version>15.1X49-D50.3</version> \r
+ <groups>\r
+ <name>node0</name>\r
+ <system>\r
+ #foreach($server in ${servers})\r
+ <server-host-name>$StringUtils.upperCase("$server")</server-host-name>\r
+ #end\r
+ </system>\r
+ <system>\r
+ <host-name>${node0_hostname}</host-name>\r
+ <backup-router>\r
+ <address>${node0_backup_router_address}</address>\r
+ <destination>$node0_backup_router_address</destination>\r
+ </backup-router>\r
+ #foreach($tacplus-server in ${tacplus-servers})\r
+ <tacplus-server>\r
+ <name>$tacplus-server.tacplus-server-name</name>\r
+ <source-address>$tacplus-server.tacplus-server-source-address</source-address>\r
+ </tacplus-server>\r
+ #end\r
+ <login>\r
+ <message>AT&T information assets</message>\r
+ #foreach($class in ${classes})\r
+ <class>\r
+ <name>$class.name</name>\r
+ <idle-timeout>$class.idle-timeout</idle-timeout>\r
+ #if ($class.permissions)\r
+ <permissions>$class.permissions</permissions>\r
+ #end\r
+ </class>\r
+ #end \r
+ <user>\r
+ <name>readonly</name>\r
+ <full-name>Read Only Account Access</full-name>\r
+ <uid>1001</uid>\r
+ <class>tacacs-base-class</class>\r
+ </user>\r
+ <user>\r
+ <name>readwrite</name>\r
+ <full-name>Read - Write Account Access</full-name>\r
+ <uid>1002</uid>\r
+ <class>tacacs-adv-class</class>\r
+ <authentication>\r
+ <encrypted-password>${system-password}</encrypted-password>\r
+ </authentication>\r
+ </user>\r
+ <user>\r
+ <name>readwrite</name>\r
+ <full-name>Emergency Access Only</full-name>\r
+ <uid>1000</uid>\r
+ <class>superuser-class</class>\r
+ <authentication>\r
+ <encrypted-password>${root-password}</encrypted-password>\r
+ </authentication>\r
+ </user>\r
+ </login>\r
+ </system> \r
+ </groups> \r
+</configuration>
\ No newline at end of file
--- /dev/null
+ <config>\r
+ <configuration>\r
+ <groups>\r
+ <name>${group-name}</name>\r
+ <routing-instances>\r
+ <instance>\r
+ <name><*></name>\r
+ <protocols>\r
+ <pim>\r
+ <dense-groups>\r
+ <dynamic-reject />\r
+ <pim-dense-group-type>\r
+ <name>224.0.1.40/32</name>\r
+ </pim-dense-group-type>\r
+ <pim-dense-group-type>\r
+ <name>224.0.1.39/32</name>\r
+ </pim-dense-group-type>\r
+ <pim-dense-group-type>\r
+ <name>224.0.0.0/4</name>\r
+ <reject />\r
+ </pim-dense-group-type>\r
+ </dense-groups>\r
+ <rp>\r
+ <auto-rp>\r
+ <discovery />\r
+ </auto-rp>\r
+ </rp>\r
+ <interface>\r
+ <name><*></name>\r
+ <disable />\r
+ <priority>1000</priority>\r
+ </interface>\r
+ <reset-tracking-bit />\r
+ </pim>\r
+ </protocols>\r
+ </instance>\r
+ </routing-instances>\r
+ </groups>\r
+ </configuration>\r
+ </config>
\ No newline at end of file