GithubHelp home page GithubHelp logo

dmtf / yang-to-redfish-converter Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 5.0 824 KB

This tool converts a YANG model file to the corresponding Redfish schema, specified in OData CSDL, in accordance with the YANG-to-CSDL Mapping Specification.

License: Other

Python 97.90% Shell 2.10%
redfish

yang-to-redfish-converter's People

Contributors

jcleung5549 avatar mraineri avatar tomasg2012 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yang-to-redfish-converter's Issues

RedfishYangExtension missing OwningEntity and Release annotations

The Travis messages

  1. CSDL Tests
    metadata/RedfishYangExtensions_v1.xml
    All namespaces have OwningEntity:
    Error: Namespace RedfishYangExtensions.v1_0_0 lacks OwningEntity!
    at schemaOwningEntityCheck (node_modules/redfishrepotest/csdl-syntax-test.js:1618:15)
    at Context. (node_modules/redfishrepotest/csdl-syntax-test.js:164:55)
    at processImmediate (internal/timers.js:461:21)
  2. CSDL Tests
    metadata/RedfishYangExtensions_v1.xml
    All versioned, non-errata namespaces have Release:
    Error: Namespace RedfishYangExtensions.v1_0_0 lacks Release term!
    at schemaReleaseCheck (node_modules/redfishrepotest/csdl-syntax-test.js:1643:15)
    at Context. (node_modules/redfishrepotest/csdl-syntax-test.js:174:72)
    at processImmediate (internal/timers.js:461:21)

Travis - Unknown element name Collection

First Travis run
openconfig_acl_v1.xml.txt

metadata/openconfig_acl_v1.xml
✗ is valid syntax
Error: Unknown element name Collection
at Schema.defaultElementParse (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:87:11)
at parseEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
at Schema.initEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:14:5)
at new Schema (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Schema.js:23:3)
at Metadata.parseDataServiceElement (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:129:25)
at Object.parseEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
at Metadata.parseDataServices (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:116:18)
at Metadata.parseElement (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:105:12)
at Object.parseEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
at Metadata.parse (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:57:18)

One CSDL file per module

Currently, the converter generates multiple CSDL files per YANG module. The Network Infrastructure TF would like the generator to create a single consolidated CSDL file per YANG module.

CSDLs are missing an Action

The generated CSDL files needs a Action element. Below is a typical message.

  3) CSDL Tests
       metadata/ietf_inet_types_v1.xml
         All EntityType defintions have Actions:
     Error: Entity Type "ietf_inet_types" does not contain an Action
      at entityTypesHaveActions (node_modules\redfishrepotest\csdl-syntax-test.js:801:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:110:59)

Travis errors on openconfig_if_aggregate_v1.xml

2 Errors

  • Invalid enum member name
  • Property not Pascal case
  19) CSDL Tests
       metadata/openconfig_if_aggregate_v1.xml
         Enum Members are valid names:
     Error: Enum member "aggregation_type" of EnumType YangTypes is invalid!
      at checkEnumMembers (node_modules\redfishrepotest\csdl-syntax-test.js:527:15)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:99:49)

  20) CSDL Tests
       metadata/openconfig_if_aggregate_v1.xml
         Properties are Pascal-cased:
     Error: Property Name "lag_type" is not Pascal-cased
      at checkPropertiesPascalCased (node_modules\redfishrepotest\csdl-syntax-test.js:537:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:102:50)

Having trouble with yang modules with "-" in name

I am trying to convert some openconfig model and get these errors:

Traceback (most recent call last):
  File "yang_to_csdl_tool.py", line 159, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "yang_to_csdl_tool.py", line 58, in execute
    result = myparser.parse_text(content)
  File "/usr/local/lib/python3.6/dist-packages/modgrammar/__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "/usr/local/lib/python3.6/dist-packages/modgrammar/__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "/usr/local/lib/python3.6/dist-packages/modgrammar/__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 7, column 13] Expected ';': Found '-telemetry";'
Traceback (most recent call last):
  File "yang_to_csdl_tool.py", line 159, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "yang_to_csdl_tool.py", line 58, in execute
    result = myparser.parse_text(content)
  File "/usr/local/lib/python3.6/dist-packages/modgrammar/__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "/usr/local/lib/python3.6/dist-packages/modgrammar/__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "/usr/local/lib/python3.6/dist-packages/modgrammar/__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 7, column 13] Expected ';': Found '-if";'

Maybe the grammer/parser assumes there is no "-" in module names? The names of the modules above are "openconfig-telemetry" and "openconfig-if" respectively. I will look and see if I can find the source of the error. These yang models can be found here: https://github.com/openconfig/public/tree/master/release/models

'Unrecognized keyword' message during openconfig model conversion

On yang-plugin branch, receiving following notification while converting https://github.com/openconfig/public/blob/master/release/models/vlan/openconfig-vlan-types.yang file:

(py3) vsawal@W109PQB7H2:~/dmtf/YANG-to-Redfish-Converter$ pyang --plugindir ./YANG-to-Redfish-Plugin --format redfish --
path ~/dmtf/public --target_dir ~/dmtf/yang_to_rf_csdl/ ~/dmtf/public/release/models/vlan/openconfig-vlan-types.yang
We don't recognize keyword ('openconfig-extensions', 'openconfig-version'), create as statement
new TYPE:: vlan-id
new TYPE:: vlan-range
new TYPE:: qinq-id
new TYPE:: qinq-id-range
new TYPE:: vlan-mode-type
new TYPE:: vlan-ref
Success writing file to disk: /home/vsawal/dmtf/yang_to_rf_csdl//openconfig_vlan_types_v1.xml
(py3) vsawal@W109PQB7H2:~/dmtf/YANG-to-Redfish-Converter$

Travis error - Unable to locate annotation (5 times)

This error was generated from 5 files

  • openconfig_acl_v1.xml looking for oc_pkt_match_types.YangType
  • openconfig_interfaces_v1.xml looking for oc_vlan_types.YangType
  • openconfig_network_instance_v1.xml looking for oc_vlan_types.YangType
  • openconfig_platform_v1.xml looking for oc_opt_types.YangType
  • openconfig_qos_v1.xml looking for oc_qos_types.YangType
2) CSDL Tests
       metadata/openconfig_acl_v1.xml
         All Annotation Terms are valid:
     Error: Unable to locate annotation term "oc_pkt_match_types.YangType"
      at checkAnnotationTerms (node_modules\redfishrepotest\csdl-syntax-test.js:566:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:112:51)
 
4) CSDL Tests
       metadata/openconfig_interfaces_v1.xml
         All Annotation Terms are valid:
     Error: Unable to locate annotation term "oc_vlan_types.YangType"
      at checkAnnotationTerms (node_modules\redfishrepotest\csdl-syntax-test.js:566:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:112:51)

 7) CSDL Tests
       metadata/openconfig_network_instance_v1.xml
         All Annotation Terms are valid:
     Error: Unable to locate annotation term "oc_vlan_types.YangType"
      at checkAnnotationTerms (node_modules\redfishrepotest\csdl-syntax-test.js:566:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:112:51)

 10) CSDL Tests
       metadata/openconfig_platform_v1.xml
         All Annotation Terms are valid:
     Error: Unable to locate annotation term "oc_opt_types.YangType"
      at checkAnnotationTerms (node_modules\redfishrepotest\csdl-syntax-test.js:566:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:112:51)

 14) CSDL Tests
       metadata/openconfig_qos_v1.xml
         All Annotation Terms are valid:
     Error: Unable to locate annotation term "oc_qos_types.YangType"
      at checkAnnotationTerms (node_modules\redfishrepotest\csdl-syntax-test.js:566:13)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:112:51)

YANG prefix unimplemented in CSDL

I am using the yang-plugin branch and pyang. In the output I don't see the prefix. For example, converting openconfig-interfaces.yang I would expect to see "oc-if" as the module name.

Travis error - unexpected close tag

CSDL files generated with YANG-2019 branch. The CSDL appears well formed, but this message occurs for some of the generated file.

(TF-Network)$ > npm test > output
(node:23028) UnhandledPromiseRejectionWarning: Error: http://redfish.dmtf.org/schemas/v1/openconfig_lldp_v1.xml: http://redfish.dmtf.org/schemas/v1/openconfig_lldp_types_v1.xml: Unexpected close tag
Line: 52
Column: 7
Char: >
    at error (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\sax\lib\sax.js:651:10)
    at strictFail (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\sax\lib\sax.js:677:7)
    at closeTag (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\sax\lib\sax.js:871:9)
    at SAXParser.write (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\sax\lib\sax.js:1436:13)
    at new XmlDocument (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\xmldoc\lib\xmldoc.js:261:15)
    at Metadata.parse (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:34:13)
    at C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\CSDLParser\lib\cache\csdlCache.js:28:14
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:23028) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:23028) UnhandledPromiseRejectionWarning: Error: http://redfish.dmtf.org/schemas/v1/rfc7223/ietf_interfaces_v1.xml: Unexpected close tag
Line: 52
Column: 7
Char: >
    at error (C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\sax\lib\sax.js:651:10)

[ietf-ip] Converter can't find "tree_node"

As quoted:

Converting [email protected] from github.com/YangModels, after removing BOM and comments.
ym5_ietf-ip.yang.txt

$ python src/yang_to_csdl_tool.py --input yangs/ym5_ietf-ip.yang --output-dir csdl/rfc7277ym
Traceback (most recent call last):
  File "src/yang_to_csdl_tool.py", line 154, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "src/yang_to_csdl_tool.py", line 63, in execute
    xml_root = build_tree_new(result, list_of_xml, logger)
  File "C:\Users\jcleung\Documents\github external\master-spmf-tools\yang-to-csdl-converter\src\csdltree.py", line 117, in build_tree_new
    build_tree_repeat(item, entity_node, schema_node, main_node, list_of_xml, logger, csdlname)
  File "C:\Users\jcleung\Documents\github external\master-spmf-tools\yang-to-csdl-converter\src\csdltree.py", line 315, in build_tree_repeat
    handlers.handle_augment(repeat_item.elements, tree_node,
NameError: name 'tree_node' is not defined

Additional context:
https://github.com/DMTF/spmf-tools/issues/151

Property with no defined type

Hello,

I'm getting some errors when trying to use odata-csdl-vallidator on a file set generated by the Yang-to-Redfish tool. I'm attaching a tar.gz file with the CSDL and yang files where the issues can be reproduced.

The tar contents will be extract into a directory named 'interfaces', and executing the command

python odata_validator.py ./interfaces/output_dir

You will see an error:

MetaData:http://redfish.dmtf.org/schemas/v1/RedfishYangExtensions_v1.xml->DataServices->Schema:RedfishYangExtensions.v1_0_0->Term:uint8->Name uint8 is already defined in schema

There is a file I named RedfishYangExtensions_v1.xml.some_fixes where I fixed this error and some other small ones (like the value 'True' to 'true'). If you rename RedfishYangExtensions_v1.xml.some_fixes to RedfishYangExtensions_v1.xml and execute the tool again, You'll stumble on an error that I think is a problem from the Yang-to-Redfish converter:

MetaData:http://redfish.dmtf.org/schemas/v1/openconfig_if_ethernet.ethernet_top.ethernet.config_v1.xml->DataServices->Schema:openconfig_if_ethernet.ethernet_top.ethernet.config.v1_0_0->EntityType:config->Property:duplex_mode->Annotation:RedfishYang.YangType->Unparsed child XML ['{http://docs.oasis-open.org/odata/ns/edm}Member', '{http://docs.oasis-open.org/odata/ns/edm}Member']

If you look after the definition of 'duplex_mode', we can see that it is defined in openconfig_if_ethernet.ethernet_interface_config_v1.xml as an EnumType, but in file openconfig_if_ethernet.ethernet_top.ethernet.config_v1.xml the property at line 67 is declared with type 'RedfishYang.duplex_mode', which does not exist. 'RedfishYang' is an alias for 'RedfishYangExtensions.v1_0_0'.

I understand that this may be happening because of OpenConfig's complex nesting of grouping/container/uses statements, I just would like to confirm this with you.

Thanks,
andre

Collection element not recognized by Travis

The converter generates a element structures in the CSDL. However, element is not recognized by Travis.

    metadata/openconfig_lacp_orig_v1.xml
      ✗ is valid syntax
      Error: Unknown element name Collection
      at Schema.defaultElementParse (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:87:11)
      at parseEntity (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
      at Schema.initEntity (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:14:5)
      at new Schema (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Schema.js:23:3)
      at Metadata.parseDataServiceElement (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:129:25)
      at Object.parseEntity (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
      at Metadata.parseDataServices (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:116:18)
      at Metadata.parseElement (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:105:12)
      at Object.parseEntity (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
      at Metadata.parse (C:\Users\jcleung\Documents\Github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:57:18)

Issue #22 still seen in `master` branch

#22
The fix is available in yang-plugin branch.

Error:

(py3) vsawal@W109PQB7H2:~/dmtf/YANG-to-Redfish-Converter$ pyang --plugindir ./YANG-to-Redfish-Plugin --format redfish --path ~/dmtf/public --target_dir ~/dmtf/yang_to_rf_csdl/ ~/dmtf/public/release/models/vlan/openconfig-vlan.yang
Uhh
Traceback (most recent call last):
  File "/home/vsawal/python-virtual-envs/py3/bin/pyang", line 450, in <module>
    run()
  File "/home/vsawal/python-virtual-envs/py3/bin/pyang", line 419, in run
    emit_obj.emit(ctx, modules, fd)
  File "./YANG-to-Redfish-Plugin/redfish.py", line 66, in emit
    xml_root = csdltree.build_tree(module, list_of_xml, logger)
  File "./YANG-to-Redfish-Plugin/rf/csdltree.py", line 145, in build_tree
    build_tree_repeat(item, schema_node, entity_node, main_node, list_of_xml, logger, prefix + csdlname + '.', topleveltypes=topleveltypes, toplevelimports=toplevelimports)
  File "./YANG-to-Redfish-Plugin/rf/csdltree.py", line 335, in build_tree_repeat
    annotation = handlers.handle_generic(yang_keyword, yang_arg, yang_children, target)
  File "./YANG-to-Redfish-Plugin/rf/statement_handlers.py", line 22, in handle_generic
    target, {'Term': redfishtypes.get_descriptive_properties_mapping(yang_keyword),
  File "./YANG-to-Redfish-Plugin/rf/redfishtypes.py", line 57, in get_descriptive_properties_mapping
    target_name = get_valid_csdl_identifier(property_name)
  File "./YANG-to-Redfish-Plugin/rf/redfishtypes.py", line 33, in get_valid_csdl_identifier
    new_name = name.replace('-', '_').replace(':', '.').replace('"', '').replace('\'', '')
AttributeError: 'tuple' object has no attribute 'replace'

Unclear how to reference generated CSDL file

openconfig_acl_v1.xml.txt

The CSDL generated from openconfig_acl.yang contains the following fragments for acl_sets and acl_set. The schema look empty. How does a mockup reference this to resolve the property definitions?

	<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="openconfig_acl.acl_set_top.acl_sets.acl_set">
		<Annotation Term="Redfish.OwningEntity" String="DMTF"/>
		<EntityType Name="acl_set" Abstract="true" BaseType="Resource.v1_0_0.Resource">
			<Annotation Term="OData.Description" String="Parameters for acl_set."/>
			<Annotation Term="OData.LongDescription" String="Parameters for acl_set."/>
			<Annotation Term="Capabilities.InsertRestrictions">
				<Record>
					<PropertyValue Property="Insertable" Bool="false"/>
				</Record>
			</Annotation>
			<Annotation Term="Capabilities.UpdateRestrictions">
				<Record>
					<PropertyValue Property="Updatable" Bool="false"/>
				</Record>
			</Annotation>
			<Annotation Term="Capabilities.DeleteRestrictions">
				<Record>
					<PropertyValue Property="Deletable" Bool="false"/>
				</Record>
			</Annotation>
		</EntityType>
	</Schema>
	<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="openconfig_acl.acl_set_top.acl_sets">
		<Annotation Term="Redfish.OwningEntity" String="DMTF"/>
		<EntityType Name="acl_sets" Abstract="true" BaseType="Resource.v1_0_0.Resource">
			<Annotation Term="OData.Description" String="Parameters for acl_sets."/>
			<Annotation Term="OData.LongDescription" String="Parameters for acl_sets."/>
			<Annotation Term="Capabilities.InsertRestrictions">
				<Record>
					<PropertyValue Property="Insertable" Bool="false"/>
				</Record>
			</Annotation>
			<Annotation Term="Capabilities.UpdateRestrictions">
				<Record>
					<PropertyValue Property="Updatable" Bool="false"/>
				</Record>
			</Annotation>
			<Annotation Term="Capabilities.DeleteRestrictions">
				<Record>
					<PropertyValue Property="Deletable" Bool="false"/>
				</Record>
			</Annotation>
		</EntityType>
	</Schema>

[VLAN model] Fault on Description statement within Type Statement

As quoted:

(Converting ieee2-dot1x-vlans-0515.yang)
ieee2-dot1x-vlans-0515-v01.yang.txt

$ python src/yang_to_csdl_tool.py --input yangs/ieee2-dot1x-vlans-0515-v01.yang --output-dir csdl/vlans
Traceback (most recent call last):
  File "src/yang_to_csdl_tool.py", line 157, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "src/yang_to_csdl_tool.py", line 56, in execute
    result = myparser.parse_text(content)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 51, column 3] Expected 'type': Found 'description "utf'

Converting openconfig-network-instance-l2.yang results in no CSDL file

The console does not display the "Success writing..." message. After a short while, the console prompt is displayed.

$ pyang --plugindir ./YANG-to-Redfish-Plugin --format redfish --path ./yangs --target_dir testdir yangs/openconfig-netw
ork-instance-l2.yang
$

No file appears in the target directory.

Fault on Choice statement within a Case statement

As quoted:

(Converting ietf-access-control-list.yang (2017.10.12)
https://github.com/YangModels/yang/blob/master/experimental/ietf/ACL-MODEL/ietf-access-control-list.yang

The YANG model has a choice statement within a case statement.

         container matches {
            description "Definitions for match criteria for this Access List Entry.";
            choice ace-type {
              description "Type of access list entry.";
              case ace-ip {
                      description "IP Access List Entry.";
                      choice ace-ip-version {...

$ python src/yang_to_csdl_tool.py --input yangs/ietf-access-control-list07.yang --output-dir csdl2/acl-07
Traceback (most recent call last):
  File "src/yang_to_csdl_tool.py", line 154, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "src/yang_to_csdl_tool.py", line 53, in execute
    result = myparser.parse_text(content)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 153, column 17] Expected 'container' or 'if-feature' or 'leaf' or '}': Found 'choice ace-ip-ve'

Additional Context: https://github.com/DMTF/spmf-tools/issues/140

[MAC model] Fault on Prefix statement within a Module statement

As quoted:

(Converting draft-fan-mac.yang)
draft-fan-mac.yang.txt

$ python src/yang_to_csdl_tool.py --input yangs/draft-fan-mac.yang --output-dir csdl/mac
Traceback (most recent call last):
  File "src/yang_to_csdl_tool.py", line 157, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "src/yang_to_csdl_tool.py", line 56, in execute
    result = myparser.parse_text(content)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 2, column 21] Expected ';': Found 'prefix mac;'

Also, the Prefix string can have alphanumerics. (e.g. "dot1Q" and "dot1x")

Travis errors in openconfig_acl_v1.xml

3 Error messages

  • Unable to locate type
  • Unable to locate annotation term
  • Pascal case violation
13) CSDL Tests
      metadata/openconfig_acl_v1.xml
        Complex Types Should Not Have Permissions:
    Error: Unable to locate type "oc_pkt_match_types.ethertype_type"
     at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:420:15)
     at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:402:5)
     at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:93:64)

 14) CSDL Tests
      metadata/openconfig_acl_v1.xml
        All Annotation Terms are valid:
    Error: Unable to locate annotation term "oc_pkt_match_types.YangType"
     at checkAnnotationTerms (node_modules\redfishrepotest\csdl-syntax-test.js:516:13)
     at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:98:51)

 15) CSDL Tests
      metadata/openconfig_acl_v1.xml
        Properties are Pascal-cased:
    Error: Property Name "interface" is not Pascal-cased
     at checkPropertiesPascalCased (node_modules\redfishrepotest\csdl-syntax-test.js:537:13)
     at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:102:50)

No code generated for 'augment' statement

Hello,

I am having problems with the 'augment' statement. What I'm trying to do is to generate CSDL file based on OpenConfig models, but one of the blocks I'm facing is about augmenting modules. When I augment some container for example, I can't get the CSDL files to reflect this augmenting.

This is reproducible with a minimal crafted example. Take for example file minimal_base.yang file:

module minimal_base {
  yang-version "1";

  // namespace
  namespace "http://minimal-base";

  prefix "base";

  container base_container {
    leaf id {
      type uint32;
    }
  }
}

And file minimal.yang :

module minimal {
  yang-version "1";

  // namespace
  namespace "http://minimal";

  prefix "m";

  import minimal_base { prefix base; }

  augment "/base:base_container" {
    leaf name {
      type string;
    }
  }
}

The generated minimal_v1.xml has no reference whatsoever to property 'id' from minimal_base and also does not have the property 'name' defined.

...
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="minimal.v1_0_0" Alias="m">
    <Annotation Term="Redfish.OwningEntity" String="DMTF"/>
    <Annotation Term="RedfishYang.yang_version" String="1"/>
    <Annotation Term="RedfishYang.namespace" String="http://minimal"/>
    <Annotation Term="RedfishYang.prefix" String="m"/>
    <Annotation Term="RedfishYang.augment" String="/base:base_container">
        <Annotation Term="RedfishYang.leaf" String="name">
            <Annotation Term="RedfishYang.type" String="string"/>
            </Annotation>
        </Annotation>
    <EntityType Name="minimal" BaseType="minimal.minimal">
        <Annotation Term="RedfishYang.NodeTypes" EnumMember="RedfishYang.NodeTypes/module"/>
    </EntityType>
</Schema>
...

Am I doing something wrong? I expected to have a CSDL file where an entity 'minimal' with both propertied (id and name) in it, or that entity 'minimal' inherited 'id' from some other base entity.

Thanks,
andré

Property Type attributes shall be defined in Redfish.Yang.Extensions_v1.xml

In some YANG code, the import statement is used to define a namespace alias. The namespace is used later in the type statement.

module ietf-interfaces {
	namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
	prefix if;
	import ietf-yang-types {
		prefix yang;
	}
   . . .
	leaf last-change {
		type yang:date-and-time;
		. . .
	}

Correct.

<Property Name="last-change" Type="Redfish.Yang.date-and-time">
  <Annotation Term="Redfish.Yang.NodeType" EnumMember="Redfish.Yang.NodeTypes/leaf" />
  <Annotation Term="Redfish.Yang.YangType" EnumMember="Redfish.Yang.YangTypes/date-and-time" />

In addition, the entry (date-and-time) should exist in Redfish.Yang.Extensions_v1.xml in both the YangTypes enumeration and the as a TERM definition

Incorrect.

<Property Name="last-change" Type="Redfish.Yang.yang:date-and-time">
  <Annotation Term="Redfish.Yang.NodeType" EnumMember="Redfish.Yang.NodeTypes/leaf" />
  <Annotation Term="Redfish.Yang.YangType" EnumMember="Redfish.Yang.YangTypes/yang:date-and-time" />

The converter currently converts the leaf to the following CSDL property. The resultant Type attributed is not meaning CSDL.

    <Property Name="ip" Type="Yang.inet:ipv4-address-no-zone">
      <Annotation Term="Redfish.Yang.NodeType" EnumMember="Redfish.Yang.NodeTypes/leaf"/>
      <Annotation Term="Redfish.Yang.YangType" EnumMember="Redfish.Yang.YangTypes/inet:ipv4-address-no-zone"/>
      <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
      <Annotation Term="OData.Description" String="The IPv4 address on the interface."/>
    </Property>

Travis error - Unknown attribute name Alias (3 times)

42) CSDL Tests
       metadata/openconfig_network_instance_l2_v1.xml
         "before all" hook:
     Uncaught Error: Unknown attribute name Alias
      at Annotation.parseAttribute (node_modules\CSDLParser\lib\ParserCommon.js:77:13)
      at Annotation.parseEntity (node_modules\CSDLParser\lib\ParserCommon.js:30:12)
      at Annotation.init (node_modules\CSDLParser\lib\ParserCommon.js:14:12)
      at new Annotation (node_modules\CSDLParser\lib\Annotation.js:22:10)
      at Schema.parseChildElement (node_modules\CSDLParser\lib\ParserCommon.js:72:28)
      at C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:10
      at XmlElement.eachChild (node_modules\xmldoc\lib\xmldoc.js:97:20)
      at Schema.parseEntity (node_modules\CSDLParser\lib\ParserCommon.js:25:13)
      at Schema.init (node_modules\CSDLParser\lib\ParserCommon.js:14:12)
      at new Schema (node_modules\CSDLParser\lib\Schema.js:26:10)
      at C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:74:27
      at XmlElement.eachChild (node_modules\xmldoc\lib\xmldoc.js:97:20)
      at Metadata.parseDataServices (node_modules\CSDLParser\lib\Metadata.js:69:13)
      at C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:52:23
      at XmlDocument.XmlElement.eachChild (node_modules\xmldoc\lib\xmldoc.js:97:20)
      at Metadata.parse (node_modules\CSDLParser\lib\Metadata.js:41:9)
      at Object.module.exports.parseMetadata (node_modules\CSDLParser\lib\Metadata.js:97:10)
      at C:\Users\jcleung\Documents\GitHub External\branch-networktf\Redfish\node_modules\CSDLParser\lib\Metadata.js:121:20
      at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

Travis warning - Complex Types Should Not have Permissions (5 times)

Error occurs in 5 files:

  • openconfig_network_instance_v1.xml
  • openconfig_platform_transceiver_v1.xml
  • openconfig_platform_v1.xml
  • openconfig_qos_v1.xml
  • openconfig_vlan_v1.xml
 6) CSDL Tests
       metadata/openconfig_network_instance_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_vlan_types.vlan_id"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

 8) CSDL Tests
       metadata/openconfig_platform_transceiver_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "openconfig_platform.v1_0_0.present"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

9) CSDL Tests
       metadata/openconfig_platform_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_opt_types.frequency_type"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

13) CSDL Tests
       metadata/openconfig_qos_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_qos_types.queue_behavior"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

15) CSDL Tests
       metadata/openconfig_vlan_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "openconfig_network_instance.v1_0_0.status"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

Travis error - Unable to locate type (6 times)

This error was generated by 6 files

  • openconfig_acl_v1.xml looking for oc_pkt_match_types.ethertype_type
  • openconfig_interfaces_v1.xml looking for oc_vlan_types.vlan_id
  • openconfig_platform_transceiver_v1.xml looking for openconfig_platform.v1_0_0.present
  • openconfig_platform_v1.xml looking for oc_opt_types.frequency_type
  • openconfig_qos_v1.xml looking for oc_qos_types.queue_behavior
  • openconfig_vlan_v1.xml looking for openconfig_network_instance.v1_0_0.status
1) CSDL Tests
       metadata/openconfig_acl_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_pkt_match_types.ethertype_type"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

3) CSDL Tests
       metadata/openconfig_interfaces_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "openconfig_if_ethernet.v1_0_0.duplex_mode"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

 6) CSDL Tests
       metadata/openconfig_network_instance_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_vlan_types.vlan_id"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

  8) CSDL Tests
       metadata/openconfig_platform_transceiver_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "openconfig_platform.v1_0_0.present"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

  9) CSDL Tests
       metadata/openconfig_platform_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_opt_types.frequency_type"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

 13) CSDL Tests
       metadata/openconfig_qos_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "oc_qos_types.queue_behavior"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

15) CSDL Tests
       metadata/openconfig_vlan_v1.xml
         Complex Types Should Not Have Permissions:
     Error: Unable to locate type "openconfig_network_instance.v1_0_0.status"
      at checkComplexTypePermissionsInSchema (node_modules\redfishrepotest\csdl-syntax-test.js:452:15)
      at complexTypesPermissions (node_modules\redfishrepotest\csdl-syntax-test.js:434:5)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:106:64)

Unresolved reference error while converting OpenConfig Yang file CSDL to JSON

Steps to reproduce: Using file openconfig-if-ip.yang

  1. Convert OpenConfig Yang to CSDL using YANG-to-Redfish-Converter plugin:
pyang --plugindir ./YANG-to-Redfish-Plugin --format redfish --path ~/dmtf/public
 --target_dir ~/dmtf/yang_to_rf_csdl/ ~/dmtf/public/release/models/interfaces/op
enconfig-if-ip.yang
  1. Step 1 generates a bunch of CSDL files in destination folder. Use Redfish-Tools/csdl-to-json-converter/csdl-to-json.py to convert CSDL to JSON:
python  csdl-to-json.py --input generated_csdl_files --output csdl-to
-json/ --config dmtf-config.json
  1. Step 2 generated unresolved reference error for attached CSDL file (as txt since it's not allowing XML attachments)
    openconfig_if_ip.ip_vrrp_config_v1.xml.txt

Errors:

Generating JSON for: openconfig_if_ip.ip_vrrp_config_v1.xml
-- ERROR: Could not resolve reference to "Edm" for "Edm.Byte"
-- ERROR: Could not resolve reference to "oc_inet" for "oc_inet.ip_address"
-- ERROR: Could not resolve reference to "Edm" for "Edm.Byte"
-- ERROR: Could not resolve reference to "RedfishYang" for "RedfishYang.uint16"
-- ERROR: Could not resolve reference to "RedfishYang" for "RedfishYang.uint16"
-- Errors detected while generating /home/vsawal/dmtf/csdl_to_json//openconfig_if_ip.ip_vrrp_config.v1_0_0.json; not creating file

Broken type references

There are cases where some Navigation Properties are pointing to invalid definitions. For example, in openconfig_acl_v1.xml, there is the following definition:

<NavigationProperty Name="aclContainer" Type="acl.acl" ContainsTarget="true">
  <Annotation Term="OData.Permissions" EnumMember="OData.Permissions/Read"/>
  <Annotation Term="OData.Description" String="Navigation property that points to a resource of acl."/>
  <Annotation Term="OData.LongDescription" String="Automatically generated."/>
  <Annotation Term="OData.AutoExpandReferences"/>
</NavigationProperty>

acl.acl is not a valid type. There is no namespace named acl.

Add proper support for RedfishYangExtensions

Must implement ability to generate or add to RedfishYangExtensions xml file, based on the most basic Yang keywords/types and new created types.

  • Consider generating from scratch, keeping a skeleton base line in code then to generate the resulting complementary file.
  • Consider generating two different files, one for basic Yang definitions and another for Yang definitions by the converted .yang file
  • We must be able to accommodate for all created 'yang' types: how does this work for multiple Yang to Csdl conversions?

The conversion from OpenConfig YANG generates more CSDL files

The conversion from OpenConfig YANG files generates far more CSDL files than from IETF YANG files (~50 vs 6 files)

Note:

  1. The "top" structures are artifacts of the OpenConfig YANG constructs. Entities/CSDLs don't need to create for them, since they never appear in a mockup as a Redfish resource.
  2. Resolving #34, would collapses both the IETF files and OpenConfig files to one CSDL file, a piece.

IETF CSDL files
ietf_interfaces.interfaces_state.statistics_v1.xml
ietf_interfaces.interfaces_state_v1.xml
ietf_interfaces.interfaces_stateCollection_v1.xml
ietf_interfaces.interfaces_v1.xml
ietf_interfaces.interfacesCollection_v1.xml
ietf_interfaces_v1.xml

OpenConfig CSDL files
openconfig_interfaces.base_interface_ref_state.state_v1.xml
openconfig_interfaces.base_interface_ref_state_v1.xml
openconfig_interfaces.interface_common_config_v1.xml
openconfig_interfaces.interface_common_state_v1.xml
openconfig_interfaces.interface_counters_state.counters_v1.xml
openconfig_interfaces.interface_counters_state_v1.xml
openconfig_interfaces.interface_phys_config_v1.xml
openconfig_interfaces.interface_phys_holdtime_config_v1.xml
openconfig_interfaces.interface_phys_holdtime_state_v1.xml
openconfig_interfaces.interface_phys_holdtime_top.hold_time.config_v1.xml
openconfig_interfaces.interface_phys_holdtime_top.hold_time.state_v1.xml
openconfig_interfaces.interface_phys_holdtime_top.hold_time_v1.xml
openconfig_interfaces.interface_phys_holdtime_top_v1.xml
openconfig_interfaces.interface_ref.interface_ref.config_v1.xml
openconfig_interfaces.interface_ref.interface_ref.state_v1.xml
openconfig_interfaces.interface_ref.interface_ref_v1.xml
openconfig_interfaces.interface_ref_common_v1.xml
openconfig_interfaces.interface_ref_state.interface_ref.state_v1.xml
openconfig_interfaces.interface_ref_state.interface_ref_v1.xml
openconfig_interfaces.interface_ref_state_container.state_v1.xml
openconfig_interfaces.interface_ref_state_container_v1.xml
openconfig_interfaces.interface_ref_state_v1.xml
openconfig_interfaces.interface_ref_v1.xml
openconfig_interfaces.interfaces.interface.config_v1.xml
openconfig_interfaces.interfaces.interface.hold_time.config_v1.xml
openconfig_interfaces.interfaces.interface.hold_time.state_v1.xml
openconfig_interfaces.interfaces.interface.hold_time_v1.xml
openconfig_interfaces.interfaces.interface.state.counters_v1.xml
openconfig_interfaces.interfaces.interface.state_v1.xml
openconfig_interfaces.interfaces.interface.subinterfaces.subinterface.config_v1.xml
openconfig_interfaces.interfaces.interface.subinterfaces.subinterface.state.counters_v1.xml
openconfig_interfaces.interfaces.interface.subinterfaces.subinterface.state_v1.xml
openconfig_interfaces.interfaces.interface.subinterfaces.subinterface_v1.xml
openconfig_interfaces.interfaces.interface.subinterfaces.subinterfaceCollection_v1.xml
openconfig_interfaces.interfaces.interface.subinterfaces_v1.xml
openconfig_interfaces.interfaces.interface_v1.xml
openconfig_interfaces.interfaces.interfaceCollection_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.config_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.hold_time.config_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.hold_time.state_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.hold_time_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.state.counters_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.state_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.subinterfaces.subinterface.config_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.subinterfaces.subinterface.state.counters_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.subinterfaces.subinterface.state_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.subinterfaces.subinterface_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.subinterfaces.subinterfaceCollection_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface.subinterfaces_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interface_v1.xml
openconfig_interfaces.interfaces_top.interfaces.interfaceCollection_v1.xml
openconfig_interfaces.interfaces_top.interfaces_v1.xml
openconfig_interfaces.interfaces_top_v1.xml
openconfig_interfaces.interfaces_v1.xml (this should be a interfacesCollection)
openconfig_interfaces.sub_unnumbered_config_v1.xml
openconfig_interfaces.sub_unnumbered_state_v1.xml
openconfig_interfaces.sub_unnumbered_top.unnumbered.config_v1.xml
openconfig_interfaces.sub_unnumbered_top.unnumbered.interface_ref.config_v1.xml
openconfig_interfaces.sub_unnumbered_top.unnumbered.interface_ref.state_v1.xml
openconfig_interfaces.sub_unnumbered_top.unnumbered.interface_ref_v1.xml
openconfig_interfaces.sub_unnumbered_top.unnumbered.state_v1.xml
openconfig_interfaces.sub_unnumbered_top.unnumbered_v1.xml
openconfig_interfaces.sub_unnumbered_top_v1.xml
openconfig_interfaces.subinterfaces_config_v1.xml
openconfig_interfaces.subinterfaces_state.counters_v1.xml
openconfig_interfaces.subinterfaces_state_v1.xml
openconfig_interfaces.subinterfaces_top.subinterfaces.subinterface.config_v1.xml
openconfig_interfaces.subinterfaces_top.subinterfaces.subinterface.state.counters_v1.xml
openconfig_interfaces.subinterfaces_top.subinterfaces.subinterface.state_v1.xml
openconfig_interfaces.subinterfaces_top.subinterfaces.subinterface_v1.xml
openconfig_interfaces.subinterfaces_top.subinterfaces.subinterfaceCollection_v1.xml
openconfig_interfaces.subinterfaces_top.subinterfaces_v1.xml
openconfig_interfaces.subinterfaces_top_v1.xml
openconfig_interfaces_v1.xml

[Bridge model] Fault when Include statement value is alphanumeric

As quoted:

(Converting ieee2-dot1Q-bridge.yang)
ieee2-dot1Q-bridge.yang.txt

Traceback (most recent call last):
  File "src/yang_to_csdl_tool.py", line 157, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "src/yang_to_csdl_tool.py", line 56, in execute
    result = myparser.parse_text(content)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 8, column 14] Expected 'anyxml' or 'augment' or 'choice' or 'contact' or 'container' or 'description' or 'deviation' or 'feature' or 'grouping' or 'identity' or 'import' or 'include' or 'namespace' or 'notification' or 'organization' or 'prefix' or 'reference' or 'revision' or 'rpc' or 'submodule' or 'typedef' or 'yang-version' or '}': Found '1Q-types; '

Followup comments:
Periods are NOT allowed in CSDL, Yang files use UTF-8

https://github.com/DMTF/spmf-tools/issues/167

Additional issues:
Can we parse UTF-8 completely with modgrammar?

Travis complains for <Annotation> elements

Travis complains when an element is within another element.

   metadata/NetworkDevice_v1.xml
      ✗ is valid syntax
      Error: http://redfish.dmtf.org/schemas/v1/openconfig_acl_v1.xml: Unknown element name Annotation
      at Annotation.defaultElementParse (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:87:11)
      at parseEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
      at Annotation.initEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:14:5)
      at new Annotation (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Annotation.js:19:3)
      at Property.defaultElementParse (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:84:28)
      at parseEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)
      at Property.initEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:14:5)
      at new Property (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\Property.js:22:3)
      at EntityType.defaultElementParse (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:84:28)
      at parseEntity (C:\Users\jcleung\Documents\github external\branch-networktf\Redfish\node_modules\CSDLParser\lib\ParserCommon.js:26:11)

Fault on Default statement within a Choice statement

As quoted:

(Converting ietf-access-control-list.yang (2017.10.12)
https://github.com/YangModels/yang/blob/master/experimental/ietf/ACL-MODEL/ietf-access-control-list.yang

The YANG model has a default statement within a choice statement.

        container actions {
            description "Definitions of action criteria for this Access List Entry.";
            choice packet-handling {
              default "deny";
              description "Packet handling action.";
              case deny {
                leaf deny {
                  type empty;
                  description "Deny action.";
                }
              }...

$ python src/yang_to_csdl_tool.py --input yangs/ietf-access-control-list07a.yang --output-dir csdl2/acl-07
Traceback (most recent call last):
  File "src/yang_to_csdl_tool.py", line 154, in <module>
    execute(filename, args.output_grammar, args.target_dir, logger)
  File "src/yang_to_csdl_tool.py", line 53, in execute
    result = myparser.parse_text(content)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 508, in parse_text
    for result in self._parse_text(string, bol, eof, data, matchtype):
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 455, in _parse_text
    count, obj = self._parse(pos, session, matchtype)
  File "C:\Users\jcleung\AppData\Local\Programs\Python\Python35-32\lib\site-packages\modgrammar\__init__.py", line 395, in _parse
    raise ParseError(self.grammar, self.text.string, errpos, char, line=line, col=col, expected=expected)
modgrammar.ParseError: [line 165, column 15] Expected 'case' or 'container' or 'description' or 'leaf' or 'mandatory' or '}': Found 'default "deny";'

Travis error - RedfishYangExtensions.v1_0_0 needs OwningEntity and Release terms

16) CSDL Tests
       metadata/RedfishYangExtensions_v1.xml
         All namespaces have OwningEntity:
     Error: Namespace RedfishYangExtensions.v1_0_0 lacks OwningEntity!
      at schemaOwningEntityCheck (node_modules\redfishrepotest\csdl-syntax-test.js:1530:15)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:124:55)

17) CSDL Tests
       metadata/RedfishYangExtensions_v1.xml
         All versioned, non-errata namespaces have Release:
     Error: Namespace RedfishYangExtensions.v1_0_0 lacks Release term!
      at schemaReleaseCheck (node_modules\redfishrepotest\csdl-syntax-test.js:1555:15)
      at Context.it (node_modules\redfishrepotest\csdl-syntax-test.js:136:72)

Unrecognized keyword - openconfig-extensions

A CSDL file was create, but got the following warning messages.

(yang-2019)$ pyang -p yangs --plugindir ./YANG-to-Redfish-Plugin --format redfish --target_dir output_dir --combine_all_nodes yangs/openconfig-acl.yang
We don't recognize keyword ('openconfig-extensions', 'openconfig-version'), create as statement
Success writing file to disk: output_dir/openconfig_acl_v1.xml

Checklist for supported tags

  • 6 YANG statement mapping format
  • 6.1.5 Namespace
  • 6.2.1 Belongs-to
  • 6.4.2 Path
  • 6.4.3 require-instance
  • 6.4.4 Mapping special types
  • 6.8.3 Key
  • 6.10 Anyxml
  • 6.12.1 Refine
  • 6.13 Rpc
  • 6.13.2 Input
  • 6.13.3 Output
  • 6.14 Notification
  • 6.16.2 Base
  • 6.17 Extension
  • 6.18 Argument
  • 6.1 Module
  • 6.1.3 Import
  • 6.1.4 Include
  • 6.1.6 Prefix
  • 6.2 Submodule
  • 6.3 Typedef
  • 6.3.2 Default
  • 6.4 Type
  • 6.5 Container
  • 6.6 Leaf
  • 6.7 Leaf-list
  • 6.8 List
  • 6.9 Choice
  • 6.9.3 Case
  • 6.11 Grouping
  • 6.12 Uses
  • 6.15 Augment
  • 6.16 Identity
  • 6.21 Deviation
  • 6.22 Deviate
  • 6.23 Config
  • 6.24 Status
  • 6.19 Feature
  • 6.20 If-feature
  • 6.25 Description
  • 6.26 Reference
  • 6.27 When
  • 6.28 Unmapped YANG statements
  • Property keywords related to CSDL int ranges, regex patterns...

Checklist in progress of being filled out, some of which might already be covered but are unchecked.
Anything in bold would might need to be double check.

Error converting Openconfig Vlan yang

The following error is reported when trying to convert file openconfig-vlan.yang:

Traceback (most recent call last):
  File "/home/ipedasia/prjs/swo/venv/bin/pyang", line 450, in <module>
    run()
  File "/home/ipedasia/prjs/swo/venv/bin/pyang", line 419, in run
    emit_obj.emit(ctx, modules, fd)
  File "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/redfish.py", line 66, in emit
    xml_root = csdltree.build_tree(module, list_of_xml, logger)
  File "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/rf/csdltree.py", line 145, in build_tree
    build_tree_repeat(item, schema_node, entity_node, main_node, list_of_xml, logger, prefix + csdlname + '.', topleveltypes=topleveltypes, toplevelimports=toplevelimports)
  File "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/rf/csdltree.py", line 335, in build_tree_repeat
    annotation = handlers.handle_generic(yang_keyword, yang_arg, yang_children, target)
  File "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/rf/statement_handlers.py", line 22, in handle_generic
    target, {'Term': redfishtypes.get_descriptive_properties_mapping(yang_keyword),
  File "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/rf/redfishtypes.py", line 57, in get_descriptive_properties_mapping
    target_name = get_valid_csdl_identifier(property_name) 
  File "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/rf/redfishtypes.py", line 33, in get_valid_csdl_identifier
    new_name = name.replace('-', '_').replace(':', '.').replace('"', '').replace('\'', '')
AttributeError: 'tuple' object has no attribute 'replace'

The problem seens to be an error of not recognizing the keywords 'openconfig-extensions' and 'openconfig-version' onlines 16 and 29 respectively on file openconfig-vlan.yang.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.