DMTF / YANG-to-Redfish-Converter

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.
Other
4 stars 5 forks source link

Error converting Openconfig Vlan yang #22

Closed dorado18 closed 6 years ago

dorado18 commented 6 years ago

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.

tomasg2012 commented 6 years ago

This is an issue I had come across but hadn't done research on what the keywords actually meant, since they were not prefixed by any yang keywords. It seems pyang spits out something different as a result, but I don't know exactly why or what I'm supposed to do with it.

But in particular, what does the keyword mean? From what I'm reading, it has to do with language extensions? Does pyang support this, and should the converter in spite of that?

dorado18 commented 6 years ago

'openconfig-extensions' is a module defined in openconfig-extensions.yang. Maybe this module is not being parsed correctly in the 'import' statement ?

When reaching "/home/ipedasia/prjs/swo/YANG-to-Redfish-Converter/YANG-to-Redfish-Plugin/rf/csdltree.py", line 335, 'yang_keyword' variable has as value a tuple ('openconfig-extensions', 'openconfig-version')

I don't know pyang nor the yang to csdl specification enough to answer your last questions.

Thanks

tomasg2012 commented 6 years ago

I think it's clearly being imported seeing as the alias is properly parsed, but I'll have to do research to see if pyang is doing anything more about it, and what's contained in the conversion spec. Do you know if this format of "importname:importitem" in Yang files as a Keyword subsititute is only to deal with extensions?

I will report back or contact @jcleung5549 for more info about how to handle extensions. I believe they can be treated like a csdl Annotation with an enum.

e.g. <Annotation "YangCustom.Keyword" "oc_ext/openconfig_version">, where the latter is the extension generated as an enum for a term. A more complicated mockup may be necessary, and the spec must be checked.

tomasg2012 commented 6 years ago

Should perform better on the latest branch yang-plugin, along with e-mail based issues.

jcleung5549 commented 6 years ago

The latest update doesn't exhibit this problem. See issue #19 for the output from a current execution. Changed 'label' to "fixed". Issue originator should "close" issue, if satisfied.