aboutsummaryrefslogtreecommitdiffstats
path: root/appc-sdc-listener/appc-yang-generator
diff options
context:
space:
mode:
Diffstat (limited to 'appc-sdc-listener/appc-yang-generator')
-rw-r--r--appc-sdc-listener/appc-yang-generator/pom.xml97
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/YANGGenerator.java49
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/exception/YANGGenerationException.java51
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorFactory.java52
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorImpl.java176
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/objects/Leaf.java72
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/type/YangTypes.java108
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/main/resources/templates/YangTemplate.vm47
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/test/java/org/openecomp/appc/TestYANGGenerator.java197
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFile.yml319
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithSyntaxError.yml319
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithUnsupportedTypes.yml373
-rw-r--r--appc-sdc-listener/appc-yang-generator/src/test/resources/yang/expectedYang.yang345
13 files changed, 2205 insertions, 0 deletions
diff --git a/appc-sdc-listener/appc-yang-generator/pom.xml b/appc-sdc-listener/appc-yang-generator/pom.xml
new file mode 100644
index 000000000..abe531e35
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+============LICENSE_START=======================================================
+ONAP : APPC
+================================================================================
+Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+================================================================================
+Copyright (C) 2017 Amdocs
+=============================================================================
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ECOMP is a trademark and service mark of AT&T Intellectual Property.
+============LICENSE_END=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-sdc-listener</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>appc-yang-generator</artifactId>
+ <packaging>jar</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-parser-impl</artifactId>
+ <version>${odl.yangtools.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-tosca-datatype</artifactId>
+ <version>${toscalib.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <finalName>${artifactId}-${version}</finalName>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.6.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/YANGGenerator.java b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/YANGGenerator.java
new file mode 100644
index 000000000..562c4abf2
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/YANGGenerator.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.yang;
+
+import org.openecomp.appc.yang.exception.YANGGenerationException;
+
+import java.io.OutputStream;
+
+/**
+ * The Interface YANGGenerator - provides method to generate YANG file from TOSCA.
+ */
+public interface YANGGenerator {
+
+ /**
+ * Generate YANG from TOSCA.
+ * if any exceptional Type is coming in the input tosca as a part of configuration parameter property, YANGGenerationException will be thrown.
+ * This API is not supporting below mentioned built-in Types:
+ * bits, decimal64, enumeration, identityref, leafref, union
+ *
+ * @param uniqueID - Set as module name in the yang, mandatory, cannot be null or empty
+ * @param tosca - TOSCA String from which the YANG is to be generated, mandatory, cannot be null or empty
+ * @param stream - The outputStream to which the generated yang is written, mandatory, cannot be null
+ * @throws YANGGenerationException - Thrown when any error occurred during method execution, the origin can be found from ex.getCause() or ex.getMessage()
+ */
+
+ void generateYANG(String uniqueID, String tosca, OutputStream stream) throws YANGGenerationException;
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/exception/YANGGenerationException.java b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/exception/YANGGenerationException.java
new file mode 100644
index 000000000..a37d6f685
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/exception/YANGGenerationException.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.yang.exception;
+
+/**
+ * The Class YANGGenerationException.
+ */
+public class YANGGenerationException extends Exception {
+
+
+ /**
+ * Instantiates a new YANG generation exception.
+ *
+ * @param message - the appropriate message
+ * @param cause -the appropriate cause
+ */
+ public YANGGenerationException(String message,Throwable cause){
+ super(message,cause);
+ }
+
+
+ /**
+ * Instantiates new YANG generation exception
+ * @param message
+ */
+ public YANGGenerationException(String message){
+ super(message);
+ }
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorFactory.java b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorFactory.java
new file mode 100644
index 000000000..25d9b211a
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorFactory.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.yang.impl;
+
+import org.openecomp.appc.yang.YANGGenerator;
+
+/**
+ * A factory for creating YANGGenerator objects.
+ */
+public class YANGGeneratorFactory {
+
+ private YANGGeneratorFactory(){}
+
+ private static class InstanceHolder
+ {
+ private static YANGGeneratorImpl instance = new YANGGeneratorImpl();
+ private InstanceHolder(){}
+ }
+
+ /**
+ * Gets the YANG generator.
+ *
+ * @return the YANG generator
+ */
+ public static YANGGenerator getYANGGenerator()
+ {
+ return InstanceHolder.instance;
+ }
+
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorImpl.java b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorImpl.java
new file mode 100644
index 000000000..246563932
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/impl/YANGGeneratorImpl.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.yang.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.apache.commons.lang.StringUtils;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.openecomp.appc.yang.YANGGenerator;
+import org.openecomp.appc.yang.exception.YANGGenerationException;
+import org.openecomp.appc.yang.objects.Leaf;
+import org.openecomp.appc.yang.type.YangTypes;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+
+import java.io.*;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+@SuppressWarnings("CheckStyle")
+public class YANGGeneratorImpl implements YANGGenerator {
+
+ private static final EELFLogger Log = EELFManager.getInstance().getLogger(YANGGeneratorImpl.class);
+ private static final String MODULE_TYPE = "moduleType";
+ private static final String LEAVES = "leaves";
+
+
+ /* (non-Javadoc)
+ * @see org.openecomp.appc.yang.YANGGenerator#generateYANG(java.lang.String, java.lang.String, java.io.OutputStream)
+ */
+ @Override
+ public void generateYANG(String uniqueID, String tosca, OutputStream stream)
+ throws YANGGenerationException {
+ Log.info("Entered into generateYANG.");
+ Log.debug("Received Tosca:\n" + tosca +"\n Received uniqueID: "+uniqueID);
+
+ validateInput(uniqueID, tosca, stream);
+ Map<String,Object> parsedToscaMap = parseTosca(tosca);
+ String moduleType =parsedToscaMap.get(MODULE_TYPE).toString();
+ List<Leaf> leaves = (List<Leaf>) parsedToscaMap.get(LEAVES);
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+ ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+ ve.init();
+ Template template;
+
+ try {
+ template = ve.getTemplate("templates/YangTemplate.vm");
+ } catch ( ResourceNotFoundException | ParseErrorException ex) {
+ Log.error("Error while retrieving YANG Template", ex);
+ throw new YANGGenerationException("Error while retrieving YANG Template",ex);
+ }
+
+ VelocityContext vc = new VelocityContext();
+
+ vc.put("moduleName", uniqueID);
+ vc.put(MODULE_TYPE, moduleType);
+ vc.put(LEAVES, leaves);
+
+ StringWriter sw = new StringWriter();
+ template.merge(vc,sw);
+ Log.debug("generated YANG \n "+sw.toString());
+ try {
+ String yang = sw.toString();
+ validateYang(yang);
+ stream.write(yang.getBytes());
+ stream.flush();
+ } catch (IOException e) {
+ Log.error("Error while writing to outputstream", e);
+ throw new YANGGenerationException("Error writing to outputstream",e);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ Log.error("Error while closing outputstream", e);
+ }
+ }
+ Log.info("exiting generateYANG method.");
+ }
+
+ private void validateYang(String yang) throws YANGGenerationException {
+
+ try(InputStream inputYangStream = new ByteArrayInputStream(yang.getBytes())){
+ YangStatementSourceImpl statementSource = new YangStatementSourceImpl(inputYangStream);
+ if(statementSource.getYangAST()==null){
+ throw new YANGGenerationException("Syntax Error in Generated YANG = " + yang);
+ }
+ }
+ catch(IOException e){
+ Log.error("Error validating yang file "+ yang,e);
+ throw new YANGGenerationException("Invalid YANG generated",e);
+ }
+ }
+
+ private Map<String,Object> parseTosca(String tosca) throws YANGGenerationException {
+ Log.info("Entered into parseTosca.");
+ ServiceTemplate serviceTemplate = new YamlUtil().yamlToObject(tosca, ServiceTemplate.class);
+ Map<String, NodeType> nodeTypeMap = serviceTemplate.getNode_types();
+ String kind = nodeTypeMap.keySet().toArray(new String[0])[0];
+ NodeType nodeType = nodeTypeMap.get(kind);
+ Map<String,Object> returnMap= new HashMap<>();
+ Map<String, PropertyDefinition> propertyDefinitionFromTOSCA = nodeType.getProperties();
+ returnMap.put(MODULE_TYPE, kind);
+ List<Leaf> leaves = new LinkedList<>();
+
+ for(Map.Entry<String, PropertyDefinition> entry: propertyDefinitionFromTOSCA.entrySet()){
+ Leaf leaf = new Leaf();
+ leaf.setName(entry.getKey());
+ PropertyDefinition pd = entry.getValue();
+ Map<String,String> typeMap=YangTypes.getYangTypeMap();
+ if (typeMap.containsKey(pd.getType())) {
+ String paramType = typeMap.get(pd.getType());
+ leaf.setType(paramType);
+ leaf.setDescription(!StringUtils.isEmpty(pd.getDescription()) ? pd.getDescription() : "");
+ leaf.setMandatory((pd.getRequired() != null) ? Boolean.toString(pd.getRequired()) : Boolean.toString(false));
+ leaf.setDefaultValue((pd.get_default() != null) ? pd.get_default().toString(): "");
+ leaves.add(leaf);
+ } else {
+ YANGGenerationException yangGenerationException = new YANGGenerationException(pd.getType() + " Type is not supported ", null);
+ Log.error(pd.getType() + " Type is not supported ", yangGenerationException);
+ throw yangGenerationException;
+ }
+ }
+ returnMap.put(LEAVES, leaves);
+ Log.info("exiting parseTosca method with return MAP "+returnMap);
+ return returnMap;
+ }
+
+ private void validateInput(String uniqueID, String tosca, OutputStream stream) throws YANGGenerationException {
+ Log.info("Entered into validateInput.");
+ if(StringUtils.isEmpty(uniqueID)) {
+ throw new YANGGenerationException("uniqueID is mandatory, cannot be null or empty.",null);
+ }
+ if(StringUtils.isEmpty(tosca)) {
+ throw new YANGGenerationException("tosca is mandatory, cannot be null or empty.",null);
+ }
+ if(stream == null){
+ throw new YANGGenerationException("stream is mandatory, cannot be null.",null);
+ }
+ Log.info("exiting validateInput method.");
+ }
+
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/objects/Leaf.java b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/objects/Leaf.java
new file mode 100644
index 000000000..013e31475
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/objects/Leaf.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.yang.objects;
+
+public class Leaf {
+ private String name;
+ private String type;
+ private String description;
+ private String mandatory;
+ private String defaultValue;
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public String getMandatory() {
+ return mandatory;
+ }
+ public void setMandatory(String mandatory) {
+ this.mandatory = mandatory;
+ }
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+ @Override
+ public String toString() {
+ return "Leaf [name=" + name + ", type=" + type + ", description=" + description + ", mandatory=" + mandatory
+ + ", defaultValue=" + defaultValue + "]";
+ }
+
+
+
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/type/YangTypes.java b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/type/YangTypes.java
new file mode 100644
index 000000000..ca18c4311
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/java/org/openecomp/appc/yang/type/YangTypes.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.yang.type;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class YangTypes {
+
+ private static final Map<String, String> yangTypeMap;
+ private YangTypes(){}
+ static {
+ Map<String, String> typeMap = new HashMap<>();
+
+ /* standard Types */
+ /* typeMap.put("bits","bits");
+ typeMap.put("leafref","leafref");
+ typeMap.put("decimal64","decimal64");
+ typeMap.put("enumeration","enumeration");
+ typeMap.put("identityref","identityref");
+ typeMap.put("union","union");*/
+ typeMap.put("binary","binary");
+ typeMap.put("boolean","boolean");
+ typeMap.put("empty","empty");
+ typeMap.put("instance-identifier","instance-identifier");
+ typeMap.put("int8","int8");
+ typeMap.put("int16","int16");
+ typeMap.put("int32","int32");
+ typeMap.put("int64","int64");
+ typeMap.put("string","string");
+ typeMap.put("uint8","uint8");
+ typeMap.put("uint16","uint16");
+ typeMap.put("uint32","uint32");
+ typeMap.put("uint64","uint64");
+
+
+ /* ietf-yang-types */
+
+ typeMap.put("counter32","yang:counter32");
+ typeMap.put("zero-based-counter32","yang:zero-based-counter32");
+ typeMap.put("counter64","yang:counter64");
+ typeMap.put("zero-based-counter64","yang:zero-based-counter64");
+ typeMap.put("gauge32","yang:gauge32");
+ typeMap.put("gauge64","yang:gauge64");
+ typeMap.put("object-identifier","yang:object-identifier");
+ typeMap.put("object-identifier-128","yang:object-identifier-128");
+ typeMap.put("yang-identifier","yang:yang-identifier");
+ typeMap.put("date-and-time","yang:date-and-time");
+ typeMap.put("timeticks","yang:timeticks");
+ typeMap.put("timestamp","yang:timestamp");
+ typeMap.put("phys-address","yang:phys-address");
+ typeMap.put("mac-address","yang:mac-address");
+ typeMap.put("xpath1.0","yang:xpath1.0");
+ typeMap.put("hex-string","yang:hex-string");
+ typeMap.put("uuid","yang:uuid");
+ typeMap.put("dotted-quad","yang:dotted-quad");
+
+ /* ietf-inet-types */
+
+ typeMap.put("ip-version","inet:ip-version");
+ typeMap.put("dscp","inet:dscp");
+ typeMap.put("ipv6-flow-label","inet:ipv6-flow-label");
+ typeMap.put("port-number","inet:port-number");
+ typeMap.put("as-number","inet:as-number");
+ typeMap.put("ip-address","inet:ip-address");
+ typeMap.put("ipv4-address","inet:ipv4-address");
+ typeMap.put("ipv6-address","inet:ipv6-address");
+ typeMap.put("ip-address-no-zone","inet:ip-address-no-zone");
+ typeMap.put("ipv4-address-no-zone","inet:ipv4-address-no-zone");
+ typeMap.put("ipv6-address-no-zone","inet:ipv6-address-no-zone");
+ typeMap.put("ip-prefix","inet:ip-prefix");
+ typeMap.put("ipv4-prefix","inet:ipv4-prefix");
+ typeMap.put("ipv6-prefix","inet:ipv6-prefix");
+ typeMap.put("domain-name","inet:domain-name");
+ typeMap.put("host","inet:host");
+ typeMap.put("uri","inet:uri");
+
+ yangTypeMap = Collections.unmodifiableMap(typeMap);
+ }
+
+ public static Map<String, String> getYangTypeMap(){
+ return yangTypeMap;
+ }
+
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/main/resources/templates/YangTemplate.vm b/appc-sdc-listener/appc-yang-generator/src/main/resources/templates/YangTemplate.vm
new file mode 100644
index 000000000..ab608c5e1
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/main/resources/templates/YangTemplate.vm
@@ -0,0 +1,47 @@
+module $moduleName {
+ yang-version 1;
+ namespace "org:openecomp:appc:vnf:$moduleName";
+ prefix appc-vnf;
+ organization "Copyright 2017 AT&T Intellectual Property.";
+
+ description
+ "$moduleType description";
+
+ revision "2017-01-01" {
+ description
+ "$moduleName Configuration";
+ }
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import ietf-yang-types {
+ prefix yang;
+ }
+
+ grouping vnf-config-grp {
+ container vnf-config {
+ #foreach( $data in $leaves )
+ leaf $data.getName() {
+ type $data.getType();
+ description "$data.getDescription()";
+ mandatory $data.getMandatory();
+ default "$data.getDefaultValue()";
+ }
+ #end
+}
+ }
+
+ container vnf-config-repo {
+ list vnf-config-list {
+ key "vnf-identifier";
+ leaf vnf-identifier {
+ type string;
+ }
+ uses vnf-config-grp;
+ }
+
+ }
+
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/test/java/org/openecomp/appc/TestYANGGenerator.java b/appc-sdc-listener/appc-yang-generator/src/test/java/org/openecomp/appc/TestYANGGenerator.java
new file mode 100644
index 000000000..a4487ac52
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/test/java/org/openecomp/appc/TestYANGGenerator.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc;
+
+import org.junit.*;
+import org.junit.rules.TemporaryFolder;
+import org.openecomp.appc.yang.YANGGenerator;
+import org.openecomp.appc.yang.exception.YANGGenerationException;
+import org.openecomp.appc.yang.impl.YANGGeneratorFactory;
+
+import java.io.*;
+
+/**
+ * The Class TestYANGGenerator - Junit Test Class for all related test cases.
+ */
+@Ignore
+public class TestYANGGenerator {
+
+ private YANGGenerator yangGenerator = YANGGeneratorFactory.getYANGGenerator();
+ private static String tosca;
+ private static String toscaWithSyntaxError;
+ private static String expectedYang;
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ /**
+ * Run before test method.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @Before
+ public void runBeforeTestMethod() throws IOException {
+ tosca= getFileContent("tosca/toscaFile.yml");
+ toscaWithSyntaxError = getFileContent("tosca/toscaFileWithSyntaxError.yml");
+ expectedYang = getFileContent("yang/expectedYang.yang");
+ }
+
+ /**
+ * Test YANG generator for success.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws YANGGenerationException the YANG generation exception
+ */
+ @Test
+ public void TestYANGGeneratorForSuccess() throws IOException, YANGGenerationException {
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ Assert.assertNotNull(tosca);
+ Assert.assertFalse("tosca file is emply or blank", tosca.equals(""));
+ yangGenerator.generateYANG("ATD456", tosca, out);
+ out.flush();
+ out.close();
+ String generatedYang = getFileContent(tempFile);
+ Assert.assertEquals(expectedYang,generatedYang);
+ }
+
+ @Test(expected = YANGGenerationException.class)
+ public void testYangGenerationForSyntaxError() throws IOException, YANGGenerationException {
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ yangGenerator.generateYANG("ATD456",toscaWithSyntaxError,out);
+ }
+
+
+ /**
+ * Test for Yang Generator which generates YANG that is not matching with expected YANG.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws YANGGenerationException - the YANG generation exception
+ */
+ @Test
+ public void unmatchedYangGenerationTest() throws IOException, YANGGenerationException {
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ yangGenerator.generateYANG("112476", tosca, out);
+ out.flush();
+ out.close();
+ String generatedYang = getFileContent(tempFile);
+ Assert.assertNotSame(expectedYang, generatedYang);
+
+ }
+
+ /**
+ * Yang generation test for empty tosca input.
+ *
+ * @throws YANGGenerationException the YANG generation exception
+ */
+ @Test(expected = YANGGenerationException.class)
+ public void YangGenerationTestForEmptyUniqueIDInput() throws IOException, YANGGenerationException {
+// OutputStream out = new FileOutputStream(classLoader.getResource("yang/generatedYang.yang").getFile());
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ yangGenerator.generateYANG("", tosca, out);
+ }
+
+ /**
+ * Yang generation test for empty tosca input.
+ *
+ * @throws YANGGenerationException the YANG generation exception
+ */
+ @Test(expected = YANGGenerationException.class)
+ public void YangGenerationTestForUnSupportedType() throws IOException, YANGGenerationException {
+ tosca= getFileContent("tosca/toscaFileWithUnsupportedTypes.yml");
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ yangGenerator.generateYANG("", tosca, out);
+ }
+
+ /**
+ * Yang generation test for empty tosca input.
+ *
+ * @throws YANGGenerationException the YANG generation exception
+ */
+ @Test(expected = YANGGenerationException.class)
+ public void YangGenerationTestForEmptyToscaInput() throws IOException, YANGGenerationException {
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ yangGenerator.generateYANG("1111", "", out);
+ }
+
+ /**
+ * YANG generation test with invalid method arguments.
+ *
+ * @throws YANGGenerationException the YANG generation exception
+ */
+ @Test(expected = YANGGenerationException.class)
+ public void YANGGenerationTestWithInvalidMethodArguments() throws YANGGenerationException {
+ yangGenerator.generateYANG("112476", "ToscaSAMPLE", null);
+ }
+
+ @Test(expected = YANGGenerationException.class)
+ public void YANGGenerationTestWithIOException() throws IOException, YANGGenerationException {
+ File tempFile = temporaryFolder.newFile("generatedYang.yang");
+ OutputStream out = new FileOutputStream(tempFile);
+ out.flush();
+ out.close();
+ yangGenerator.generateYANG("1111", tosca, out);
+ }
+
+
+ private String getFileContent(String fileName) throws IOException
+ {
+ ClassLoader classLoader = new TestYANGGenerator().getClass().getClassLoader();
+ InputStream is = new FileInputStream(classLoader.getResource(fileName).getFile());
+ BufferedReader buf = new BufferedReader(new InputStreamReader(is));
+ String line = buf.readLine();
+ StringBuilder sb = new StringBuilder();
+
+ while (line != null) {
+ sb.append(line).append("\n");
+ line = buf.readLine();
+ }
+ String fileString = sb.toString();
+ is.close();
+ return fileString;
+ }
+
+ private String getFileContent(File file) throws IOException
+ {
+ InputStream is = new FileInputStream(file);
+ BufferedReader buf = new BufferedReader(new InputStreamReader(is));
+ String line = buf.readLine();
+ StringBuilder sb = new StringBuilder();
+
+ while (line != null) {
+ sb.append(line).append("\n");
+ line = buf.readLine();
+ }
+ String fileString = sb.toString();
+ is.close();
+ return fileString;
+ }
+
+}
diff --git a/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFile.yml b/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFile.yml
new file mode 100644
index 000000000..0356678d1
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFile.yml
@@ -0,0 +1,319 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+node_types:
+ Property Definition:
+ derived_from: org.openecomp.genericvnf
+ version: V1
+ description: ''
+ properties:
+ param1:
+ type: domain-name
+ description: param1 desc
+ required: true
+ default: param1 def val
+ status: SUPPORTED
+ param2:
+ type: ipv4-address-no-zone
+ description: param2 desc
+ required: true
+ default: param2 def val
+ status: SUPPORTED
+ param3:
+ type: instance-identifier
+ description: param3 desc
+ required: true
+ default: param3 def val
+ status: SUPPORTED
+ param4:
+ type: uuid
+ description: param4 desc
+ required: true
+ default: param4 def val
+ status: SUPPORTED
+ param5:
+ type: empty
+ description: param5 desc
+ required: true
+ default: param5 def val
+ status: SUPPORTED
+ param6:
+ type: object-identifier-128
+ description: param6 desc
+ required: true
+ default: param6 def val
+ status: SUPPORTED
+ param7:
+ type: dscp
+ description: param7 desc
+ required: true
+ default: param7 def val
+ status: SUPPORTED
+ param8:
+ type: int64
+ description: param8 desc
+ required: true
+ default: param8 def val
+ status: SUPPORTED
+ param9:
+ type: zero-based-counter64
+ description: param9 desc
+ required: true
+ default: param9 def val
+ status: SUPPORTED
+ param10:
+ type: int8
+ description: param10 desc
+ required: true
+ default: param10 def val
+ status: SUPPORTED
+ param11:
+ type: host
+ description: param11 desc
+ required: true
+ default: param11 def val
+ status: SUPPORTED
+ param12:
+ type: uint32
+ description: param12 desc
+ required: true
+ default: param12 def val
+ status: SUPPORTED
+ param13:
+ type: timeticks
+ description: param13 desc
+ required: true
+ default: param13 def val
+ status: SUPPORTED
+ param15:
+ type: mac-address
+ description: param15 desc
+ required: true
+ default: param15 def val
+ status: SUPPORTED
+ param16:
+ type: as-number
+ description: param16 desc
+ required: true
+ default: param16 def val
+ status: SUPPORTED
+ param17:
+ type: counter64
+ description: param17 desc
+ required: true
+ default: param17 def val
+ status: SUPPORTED
+ param19:
+ type: xpath1.0
+ description: param19 desc
+ required: true
+ default: param19 def val
+ status: SUPPORTED
+ param20:
+ type: ip-version
+ description: param20 desc
+ required: true
+ default: param20 def val
+ status: SUPPORTED
+ param21:
+ type: port-number
+ description: param21 desc
+ required: true
+ default: param21 def val
+ status: SUPPORTED
+ param22:
+ type: int16
+ description: param22 desc
+ required: true
+ default: param22 def val
+ status: SUPPORTED
+ param23:
+ type: ipv6-address-no-zone
+ description: param23 desc
+ required: true
+ default: param23 def val
+ status: SUPPORTED
+ param24:
+ type: hex-string
+ description: param24 desc
+ required: true
+ default: param24 def val
+ status: SUPPORTED
+ param26:
+ type: uint64
+ description: param26 desc
+ required: true
+ default: param26 def val
+ status: SUPPORTED
+ param27:
+ type: uint8
+ description: param27 desc
+ required: true
+ default: param27 def val
+ status: SUPPORTED
+ param28:
+ type: ipv4-prefix
+ description: param28 desc
+ required: true
+ default: param28 def val
+ status: SUPPORTED
+ param29:
+ type: ipv6-prefix
+ description: param29 desc
+ required: true
+ default: param29 def val
+ status: SUPPORTED
+ param30:
+ type: gauge64
+ description: param30 desc
+ required: true
+ default: param30 def val
+ status: SUPPORTED
+ param31:
+ type: counter32
+ description: param31 desc
+ required: true
+ default: param31 def val
+ status: SUPPORTED
+ param32:
+ type: string
+ description: param32 desc
+ required: true
+ default: param32 def val
+ status: SUPPORTED
+ param33:
+ type: object-identifier
+ description: param33 desc
+ required: true
+ default: param33 def val
+ status: SUPPORTED
+ param34:
+ type: ip-address-no-zone
+ description: param34 desc
+ required: true
+ default: param34 def val
+ status: SUPPORTED
+ param36:
+ type: gauge32
+ description: param36 desc
+ required: true
+ default: param36 def val
+ status: SUPPORTED
+ param37:
+ type: ipv4-address
+ description: param37 desc
+ required: true
+ default: param37 def val
+ status: SUPPORTED
+ param38:
+ type: ip-prefix
+ description: param38 desc
+ required: true
+ default: param38 def val
+ status: SUPPORTED
+ param39:
+ type: uint16
+ description: param39 desc
+ required: true
+ default: param39 def val
+ status: SUPPORTED
+ param40:
+ type: timestamp
+ description: param40 desc
+ required: true
+ default: param40 def val
+ status: SUPPORTED
+ param42:
+ type: dotted-quad
+ description: param42 desc
+ required: true
+ default: param42 def val
+ status: SUPPORTED
+ param43:
+ type: uri
+ description: param43 desc
+ required: true
+ default: param43 def val
+ status: SUPPORTED
+ param44:
+ type: ipv6-address
+ description: param44 desc
+ required: true
+ default: param44 def val
+ status: SUPPORTED
+ param45:
+ type: ipv6-flow-label
+ description: param45 desc
+ required: true
+ default: param45 def val
+ status: SUPPORTED
+ param46:
+ type: zero-based-counter32
+ description: param46 desc
+ required: true
+ default: param46 def val
+ status: SUPPORTED
+ param47:
+ type: ip-address
+ description: param47 desc
+ required: true
+ default: param47 def val
+ status: SUPPORTED
+ param48:
+ type: boolean
+ description: param48 desc
+ required: true
+ default: param48 def val
+ status: SUPPORTED
+ param50:
+ type: yang-identifier
+ description: param50 desc
+ required: true
+ default: param50 def val
+ status: SUPPORTED
+ param51:
+ type: int32
+ description: param51 desc
+ required: true
+ default: param51 def val
+ status: SUPPORTED
+ param52:
+ type: date-and-time
+ description: param52 desc
+ required: true
+ default: param52 def val
+ status: SUPPORTED
+ param53:
+ type: phys-address
+ description: param53 desc
+ required: true
+ default: param53 def val
+ status: SUPPORTED
+topology_template:
+ node_templates:
+ Property Definition_Template:
+ type: Property Definition
+ properties:
+ param 1: <rule-type:rule1> <resk1:resk2 , resk2:resv2 , resk3:resv3> param1 source <reqk1:reqv1 , reqk2:reqv2 , reqk3:reqv3>
+ param 2: <rule-type:rule2> <resk1:resk2 , resk2:resv2> param2 source <reqk1:reqv1 , reqk2:reqv2 , reqk3:reqv3>
diff --git a/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithSyntaxError.yml b/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithSyntaxError.yml
new file mode 100644
index 000000000..8ef1729a9
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithSyntaxError.yml
@@ -0,0 +1,319 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+node_types:
+ Property Definition:
+ derived_from: org.openecomp.genericvnf
+ version: V1
+ description: ''
+ properties:
+ param 1:
+ type: domain-name
+ description: param1 desc
+ required: true
+ default: param1 def val
+ status: SUPPORTED
+ param2:
+ type: ipv4-address-no-zone
+ description: param2 desc
+ required: true
+ default: param2 def val
+ status: SUPPORTED
+ param3:
+ type: instance-identifier
+ description: param3 desc
+ required: true
+ default: param3 def val
+ status: SUPPORTED
+ param4:
+ type: uuid
+ description: param4 desc
+ required: true
+ default: param4 def val
+ status: SUPPORTED
+ param5:
+ type: empty
+ description: param5 desc
+ required: true
+ default: param5 def val
+ status: SUPPORTED
+ param6:
+ type: object-identifier-128
+ description: param6 desc
+ required: true
+ default: param6 def val
+ status: SUPPORTED
+ param7:
+ type: dscp
+ description: param7 desc
+ required: true
+ default: param7 def val
+ status: SUPPORTED
+ param8:
+ type: int64
+ description: param8 desc
+ required: true
+ default: param8 def val
+ status: SUPPORTED
+ param9:
+ type: zero-based-counter64
+ description: param9 desc
+ required: true
+ default: param9 def val
+ status: SUPPORTED
+ param10:
+ type: int8
+ description: param10 desc
+ required: true
+ default: param10 def val
+ status: SUPPORTED
+ param11:
+ type: host
+ description: param11 desc
+ required: true
+ default: param11 def val
+ status: SUPPORTED
+ param12:
+ type: uint32
+ description: param12 desc
+ required: true
+ default: param12 def val
+ status: SUPPORTED
+ param13:
+ type: timeticks
+ description: param13 desc
+ required: true
+ default: param13 def val
+ status: SUPPORTED
+ param15:
+ type: mac-address
+ description: param15 desc
+ required: true
+ default: param15 def val
+ status: SUPPORTED
+ param16:
+ type: as-number
+ description: param16 desc
+ required: true
+ default: param16 def val
+ status: SUPPORTED
+ param17:
+ type: counter64
+ description: param17 desc
+ required: true
+ default: param17 def val
+ status: SUPPORTED
+ param19:
+ type: xpath1.0
+ description: param19 desc
+ required: true
+ default: param19 def val
+ status: SUPPORTED
+ param20:
+ type: ip-version
+ description: param20 desc
+ required: true
+ default: param20 def val
+ status: SUPPORTED
+ param21:
+ type: port-number
+ description: param21 desc
+ required: true
+ default: param21 def val
+ status: SUPPORTED
+ param22:
+ type: int16
+ description: param22 desc
+ required: true
+ default: param22 def val
+ status: SUPPORTED
+ param23:
+ type: ipv6-address-no-zone
+ description: param23 desc
+ required: true
+ default: param23 def val
+ status: SUPPORTED
+ param24:
+ type: hex-string
+ description: param24 desc
+ required: true
+ default: param24 def val
+ status: SUPPORTED
+ param26:
+ type: uint64
+ description: param26 desc
+ required: true
+ default: param26 def val
+ status: SUPPORTED
+ param27:
+ type: uint8
+ description: param27 desc
+ required: true
+ default: param27 def val
+ status: SUPPORTED
+ param28:
+ type: ipv4-prefix
+ description: param28 desc
+ required: true
+ default: param28 def val
+ status: SUPPORTED
+ param29:
+ type: ipv6-prefix
+ description: param29 desc
+ required: true
+ default: param29 def val
+ status: SUPPORTED
+ param30:
+ type: gauge64
+ description: param30 desc
+ required: true
+ default: param30 def val
+ status: SUPPORTED
+ param31:
+ type: counter32
+ description: param31 desc
+ required: true
+ default: param31 def val
+ status: SUPPORTED
+ param32:
+ type: string
+ description: param32 desc
+ required: true
+ default: param32 def val
+ status: SUPPORTED
+ param33:
+ type: object-identifier
+ description: param33 desc
+ required: true
+ default: param33 def val
+ status: SUPPORTED
+ param34:
+ type: ip-address-no-zone
+ description: param34 desc
+ required: true
+ default: param34 def val
+ status: SUPPORTED
+ param36:
+ type: gauge32
+ description: param36 desc
+ required: true
+ default: param36 def val
+ status: SUPPORTED
+ param37:
+ type: ipv4-address
+ description: param37 desc
+ required: true
+ default: param37 def val
+ status: SUPPORTED
+ param38:
+ type: ip-prefix
+ description: param38 desc
+ required: true
+ default: param38 def val
+ status: SUPPORTED
+ param39:
+ type: uint16
+ description: param39 desc
+ required: true
+ default: param39 def val
+ status: SUPPORTED
+ param40:
+ type: timestamp
+ description: param40 desc
+ required: true
+ default: param40 def val
+ status: SUPPORTED
+ param42:
+ type: dotted-quad
+ description: param42 desc
+ required: true
+ default: param42 def val
+ status: SUPPORTED
+ param43:
+ type: uri
+ description: param43 desc
+ required: true
+ default: param43 def val
+ status: SUPPORTED
+ param44:
+ type: ipv6-address
+ description: param44 desc
+ required: true
+ default: param44 def val
+ status: SUPPORTED
+ param45:
+ type: ipv6-flow-label
+ description: param45 desc
+ required: true
+ default: param45 def val
+ status: SUPPORTED
+ param46:
+ type: zero-based-counter32
+ description: param46 desc
+ required: true
+ default: param46 def val
+ status: SUPPORTED
+ param47:
+ type: ip-address
+ description: param47 desc
+ required: true
+ default: param47 def val
+ status: SUPPORTED
+ param48:
+ type: boolean
+ description: param48 desc
+ required: true
+ default: param48 def val
+ status: SUPPORTED
+ param50:
+ type: yang-identifier
+ description: param50 desc
+ required: true
+ default: param50 def val
+ status: SUPPORTED
+ param51:
+ type: int32
+ description: param51 desc
+ required: true
+ default: param51 def val
+ status: SUPPORTED
+ param52:
+ type: date-and-time
+ description: param52 desc
+ required: true
+ default: param52 def val
+ status: SUPPORTED
+ param53:
+ type: phys-address
+ description: param53 desc
+ required: true
+ default: param53 def val
+ status: SUPPORTED
+topology_template:
+ node_templates:
+ Property Definition_Template:
+ type: Property Definition
+ properties:
+ param 1: <rule-type:rule1> <resk1:resk2 , resk2:resv2 , resk3:resv3> param1 source <reqk1:reqv1 , reqk2:reqv2 , reqk3:reqv3>
+ param 2: <rule-type:rule2> <resk1:resk2 , resk2:resv2> param2 source <reqk1:reqv1 , reqk2:reqv2 , reqk3:reqv3>
diff --git a/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithUnsupportedTypes.yml b/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithUnsupportedTypes.yml
new file mode 100644
index 000000000..e2102e134
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/test/resources/tosca/toscaFileWithUnsupportedTypes.yml
@@ -0,0 +1,373 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+node_types:
+ Property Definition:
+ derived_from: org.openecomp.genericvnf
+ version: V1
+ description: ''
+ properties:
+ param1:
+ type: domain-name
+ description: param1 desc
+ required: true
+ default: param1 def val
+ status: SUPPORTED
+ param2:
+ type: ipv4-address-no-zone
+ description: param2 desc
+ required: true
+ default: param2 def val
+ status: SUPPORTED
+ param3:
+ type: instance-identifier
+ description: param3 desc
+ required: true
+ default: param3 def val
+ status: SUPPORTED
+ param4:
+ type: uuid
+ description: param4 desc
+ required: true
+ default: param4 def val
+ status: SUPPORTED
+ param5:
+ type: empty
+ description: param5 desc
+ required: true
+ default: param5 def val
+ status: SUPPORTED
+ param6:
+ type: object-identifier-128
+ description: param6 desc
+ required: true
+ default: param6 def val
+ status: SUPPORTED
+ param7:
+ type: dscp
+ description: param7 desc
+ required: true
+ default: param7 def val
+ status: SUPPORTED
+ param8:
+ type: int64
+ description: param8 desc
+ required: true
+ default: param8 def val
+ status: SUPPORTED
+ param9:
+ type: zero-based-counter64
+ description: param9 desc
+ required: true
+ default: param9 def val
+ status: SUPPORTED
+ param10:
+ type: int8
+ description: param10 desc
+ required: true
+ default: param10 def val
+ status: SUPPORTED
+ param11:
+ type: host
+ description: param11 desc
+ required: true
+ default: param11 def val
+ status: SUPPORTED
+ param12:
+ type: uint32
+ description: param12 desc
+ required: true
+ default: param12 def val
+ status: SUPPORTED
+ param13:
+ type: timeticks
+ description: param13 desc
+ required: true
+ default: param13 def val
+ status: SUPPORTED
+ param14:
+ type: enumeration
+ description: param14 desc
+ required: true
+ default: param14 def val
+ status: SUPPORTED
+ param15:
+ type: mac-address
+ description: param15 desc
+ required: true
+ default: param15 def val
+ status: SUPPORTED
+ param16:
+ type: as-number
+ description: param16 desc
+ required: true
+ default: param16 def val
+ status: SUPPORTED
+ param17:
+ type: counter64
+ description: param17 desc
+ required: true
+ default: param17 def val
+ status: SUPPORTED
+ param18:
+ type: bits
+ description: param18 desc
+ required: true
+ default: param18 def val
+ status: SUPPORTED
+ param19:
+ type: xpath1.0
+ description: param19 desc
+ required: true
+ default: param19 def val
+ status: SUPPORTED
+ param20:
+ type: ip-version
+ description: param20 desc
+ required: true
+ default: param20 def val
+ status: SUPPORTED
+ param21:
+ type: port-number
+ description: param21 desc
+ required: true
+ default: param21 def val
+ status: SUPPORTED
+ param22:
+ type: int16
+ description: param22 desc
+ required: true
+ default: param22 def val
+ status: SUPPORTED
+ param23:
+ type: ipv6-address-no-zone
+ description: param23 desc
+ required: true
+ default: param23 def val
+ status: SUPPORTED
+ param24:
+ type: hex-string
+ description: param24 desc
+ required: true
+ default: param24 def val
+ status: SUPPORTED
+ param25:
+ type: decimal64
+ description: param25 desc
+ required: true
+ default: param25 def val
+ status: SUPPORTED
+ param26:
+ type: uint64
+ description: param26 desc
+ required: true
+ default: param26 def val
+ status: SUPPORTED
+ param27:
+ type: uint8
+ description: param27 desc
+ required: true
+ default: param27 def val
+ status: SUPPORTED
+ param28:
+ type: ipv4-prefix
+ description: param28 desc
+ required: true
+ default: param28 def val
+ status: SUPPORTED
+ param29:
+ type: ipv6-prefix
+ description: param29 desc
+ required: true
+ default: param29 def val
+ status: SUPPORTED
+ param30:
+ type: gauge64
+ description: param30 desc
+ required: true
+ default: param30 def val
+ status: SUPPORTED
+ param31:
+ type: counter32
+ description: param31 desc
+ required: true
+ default: param31 def val
+ status: SUPPORTED
+ param32:
+ type: string
+ description: param32 desc
+ required: true
+ default: param32 def val
+ status: SUPPORTED
+ param33:
+ type: object-identifier
+ description: param33 desc
+ required: true
+ default: param33 def val
+ status: SUPPORTED
+ param34:
+ type: ip-address-no-zone
+ description: param34 desc
+ required: true
+ default: param34 def val
+ status: SUPPORTED
+ param35:
+ type: identityref
+ description: param35 desc
+ required: true
+ default: param35 def val
+ status: SUPPORTED
+ param36:
+ type: gauge32
+ description: param36 desc
+ required: true
+ default: param36 def val
+ status: SUPPORTED
+ param37:
+ type: ipv4-address
+ description: param37 desc
+ required: true
+ default: param37 def val
+ status: SUPPORTED
+ param38:
+ type: ip-prefix
+ description: param38 desc
+ required: true
+ default: param38 def val
+ status: SUPPORTED
+ param39:
+ type: uint16
+ description: param39 desc
+ required: true
+ default: param39 def val
+ status: SUPPORTED
+ param40:
+ type: timestamp
+ description: param40 desc
+ required: true
+ default: param40 def val
+ status: SUPPORTED
+ param41:
+ type: union
+ description: param41 desc
+ required: true
+ default: param41 def val
+ status: SUPPORTED
+ param42:
+ type: dotted-quad
+ description: param42 desc
+ required: true
+ default: param42 def val
+ status: SUPPORTED
+ param43:
+ type: uri
+ description: param43 desc
+ required: true
+ default: param43 def val
+ status: SUPPORTED
+ param44:
+ type: ipv6-address
+ description: param44 desc
+ required: true
+ default: param44 def val
+ status: SUPPORTED
+ param45:
+ type: ipv6-flow-label
+ description: param45 desc
+ required: true
+ default: param45 def val
+ status: SUPPORTED
+ param46:
+ type: zero-based-counter32
+ description: param46 desc
+ required: true
+ default: param46 def val
+ status: SUPPORTED
+ param47:
+ type: ip-address
+ description: param47 desc
+ required: true
+ default: param47 def val
+ status: SUPPORTED
+ param48:
+ type: boolean
+ description: param48 desc
+ required: true
+ default: param48 def val
+ status: SUPPORTED
+ param49:
+ type: leafref
+ description: param49 desc
+ required: true
+ default: param49 def val
+ status: SUPPORTED
+ param50:
+ type: yang-identifier
+ description: param50 desc
+ required: true
+ default: param50 def val
+ status: SUPPORTED
+ param51:
+ type: int32
+ description: param51 desc
+ required: true
+ default: param51 def val
+ status: SUPPORTED
+ param52:
+ type: date-and-time
+ description: param52 desc
+ required: true
+ default: param52 def val
+ status: SUPPORTED
+ param53:
+ type: phys-address
+ description: param53 desc
+ required: true
+ default: param53 def val
+ status: SUPPORTED
+ param54:
+ type: phys-add
+ description: param54 desc
+ required: true
+ default: param54 def val
+ status: SUPPORTED
+ param55:
+ type: null
+ description: param55 desc
+ required: true
+ default: param55 def val
+ status: SUPPORTED
+ param56:
+ type:
+ description: param56 desc
+ required: true
+ default: param56 def val
+ status: SUPPORTED
+topology_template:
+ node_templates:
+ Property Definition_Template:
+ type: Property Definition
+ properties:
+ param 1: <rule-type:rule1> <resk1:resk2 , resk2:resv2 , resk3:resv3> param1 source <reqk1:reqv1 , reqk2:reqv2 , reqk3:reqv3>
+ param 2: <rule-type:rule2> <resk1:resk2 , resk2:resv2> param2 source <reqk1:reqv1 , reqk2:reqv2 , reqk3:reqv3>
diff --git a/appc-sdc-listener/appc-yang-generator/src/test/resources/yang/expectedYang.yang b/appc-sdc-listener/appc-yang-generator/src/test/resources/yang/expectedYang.yang
new file mode 100644
index 000000000..29c89182b
--- /dev/null
+++ b/appc-sdc-listener/appc-yang-generator/src/test/resources/yang/expectedYang.yang
@@ -0,0 +1,345 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+module ATD456 {
+ yang-version 1;
+ namespace "org:openecomp:appc:vnf:ATD456";
+ prefix appc-vnf;
+ organization "Copyright 2017 AT&T Intellectual Property.";
+
+ description
+ "Property Definition description";
+
+ revision "2017-01-01" {
+ description
+ "ATD456 Configuration";
+ }
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ import ietf-yang-types {
+ prefix yang;
+ }
+
+ grouping vnf-config-grp {
+ container vnf-config {
+ leaf param1 {
+ type inet:domain-name;
+ description "param1 desc";
+ mandatory true;
+ default "param1 def val";
+ }
+ leaf param2 {
+ type inet:ipv4-address-no-zone;
+ description "param2 desc";
+ mandatory true;
+ default "param2 def val";
+ }
+ leaf param3 {
+ type instance-identifier;
+ description "param3 desc";
+ mandatory true;
+ default "param3 def val";
+ }
+ leaf param4 {
+ type yang:uuid;
+ description "param4 desc";
+ mandatory true;
+ default "param4 def val";
+ }
+ leaf param5 {
+ type empty;
+ description "param5 desc";
+ mandatory true;
+ default "param5 def val";
+ }
+ leaf param6 {
+ type yang:object-identifier-128;
+ description "param6 desc";
+ mandatory true;
+ default "param6 def val";
+ }
+ leaf param7 {
+ type inet:dscp;
+ description "param7 desc";
+ mandatory true;
+ default "param7 def val";
+ }
+ leaf param8 {
+ type int64;
+ description "param8 desc";
+ mandatory true;
+ default "param8 def val";
+ }
+ leaf param9 {
+ type yang:zero-based-counter64;
+ description "param9 desc";
+ mandatory true;
+ default "param9 def val";
+ }
+ leaf param10 {
+ type int8;
+ description "param10 desc";
+ mandatory true;
+ default "param10 def val";
+ }
+ leaf param11 {
+ type inet:host;
+ description "param11 desc";
+ mandatory true;
+ default "param11 def val";
+ }
+ leaf param12 {
+ type uint32;
+ description "param12 desc";
+ mandatory true;
+ default "param12 def val";
+ }
+ leaf param13 {
+ type yang:timeticks;
+ description "param13 desc";
+ mandatory true;
+ default "param13 def val";
+ }
+ leaf param15 {
+ type yang:mac-address;
+ description "param15 desc";
+ mandatory true;
+ default "param15 def val";
+ }
+ leaf param16 {
+ type inet:as-number;
+ description "param16 desc";
+ mandatory true;
+ default "param16 def val";
+ }
+ leaf param17 {
+ type yang:counter64;
+ description "param17 desc";
+ mandatory true;
+ default "param17 def val";
+ }
+ leaf param19 {
+ type yang:xpath1.0;
+ description "param19 desc";
+ mandatory true;
+ default "param19 def val";
+ }
+ leaf param20 {
+ type inet:ip-version;
+ description "param20 desc";
+ mandatory true;
+ default "param20 def val";
+ }
+ leaf param21 {
+ type inet:port-number;
+ description "param21 desc";
+ mandatory true;
+ default "param21 def val";
+ }
+ leaf param22 {
+ type int16;
+ description "param22 desc";
+ mandatory true;
+ default "param22 def val";
+ }
+ leaf param23 {
+ type inet:ipv6-address-no-zone;
+ description "param23 desc";
+ mandatory true;
+ default "param23 def val";
+ }
+ leaf param24 {
+ type yang:hex-string;
+ description "param24 desc";
+ mandatory true;
+ default "param24 def val";
+ }
+ leaf param26 {
+ type uint64;
+ description "param26 desc";
+ mandatory true;
+ default "param26 def val";
+ }
+ leaf param27 {
+ type uint8;
+ description "param27 desc";
+ mandatory true;
+ default "param27 def val";
+ }
+ leaf param28 {
+ type inet:ipv4-prefix;
+ description "param28 desc";
+ mandatory true;
+ default "param28 def val";
+ }
+ leaf param29 {
+ type inet:ipv6-prefix;
+ description "param29 desc";
+ mandatory true;
+ default "param29 def val";
+ }
+ leaf param30 {
+ type yang:gauge64;
+ description "param30 desc";
+ mandatory true;
+ default "param30 def val";
+ }
+ leaf param31 {
+ type yang:counter32;
+ description "param31 desc";
+ mandatory true;
+ default "param31 def val";
+ }
+ leaf param32 {
+ type string;
+ description "param32 desc";
+ mandatory true;
+ default "param32 def val";
+ }
+ leaf param33 {
+ type yang:object-identifier;
+ description "param33 desc";
+ mandatory true;
+ default "param33 def val";
+ }
+ leaf param34 {
+ type inet:ip-address-no-zone;
+ description "param34 desc";
+ mandatory true;
+ default "param34 def val";
+ }
+ leaf param36 {
+ type yang:gauge32;
+ description "param36 desc";
+ mandatory true;
+ default "param36 def val";
+ }
+ leaf param37 {
+ type inet:ipv4-address;
+ description "param37 desc";
+ mandatory true;
+ default "param37 def val";
+ }
+ leaf param38 {
+ type inet:ip-prefix;
+ description "param38 desc";
+ mandatory true;
+ default "param38 def val";
+ }
+ leaf param39 {
+ type uint16;
+ description "param39 desc";
+ mandatory true;
+ default "param39 def val";
+ }
+ leaf param40 {
+ type yang:timestamp;
+ description "param40 desc";
+ mandatory true;
+ default "param40 def val";
+ }
+ leaf param42 {
+ type yang:dotted-quad;
+ description "param42 desc";
+ mandatory true;
+ default "param42 def val";
+ }
+ leaf param43 {
+ type inet:uri;
+ description "param43 desc";
+ mandatory true;
+ default "param43 def val";
+ }
+ leaf param44 {
+ type inet:ipv6-address;
+ description "param44 desc";
+ mandatory true;
+ default "param44 def val";
+ }
+ leaf param45 {
+ type inet:ipv6-flow-label;
+ description "param45 desc";
+ mandatory true;
+ default "param45 def val";
+ }
+ leaf param46 {
+ type yang:zero-based-counter32;
+ description "param46 desc";
+ mandatory true;
+ default "param46 def val";
+ }
+ leaf param47 {
+ type inet:ip-address;
+ description "param47 desc";
+ mandatory true;
+ default "param47 def val";
+ }
+ leaf param48 {
+ type boolean;
+ description "param48 desc";
+ mandatory true;
+ default "param48 def val";
+ }
+ leaf param50 {
+ type yang:yang-identifier;
+ description "param50 desc";
+ mandatory true;
+ default "param50 def val";
+ }
+ leaf param51 {
+ type int32;
+ description "param51 desc";
+ mandatory true;
+ default "param51 def val";
+ }
+ leaf param52 {
+ type yang:date-and-time;
+ description "param52 desc";
+ mandatory true;
+ default "param52 def val";
+ }
+ leaf param53 {
+ type yang:phys-address;
+ description "param53 desc";
+ mandatory true;
+ default "param53 def val";
+ }
+ }
+ }
+
+ container vnf-config-repo {
+ list vnf-config-list {
+ key "vnf-identifier";
+ leaf vnf-identifier {
+ type string;
+ }
+ uses vnf-config-grp;
+ }
+
+ }
+
+}