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

No code generated for 'augment' statement #23

Closed dorado18 closed 6 years ago

dorado18 commented 6 years ago

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é

tomasg2012 commented 6 years ago

The example of the proper way to augment using pyang requires listing the augmentor minimal.yang after the augmentee minimal_base.yang. Example below:

% ~/.local/bin/pyang --plugindir ./YANG-to-Redfish-Plugin -p ./ --format redfish ./minimal_base.yang ./minimal.yang

Since the augmented item is base_container, it will generate minimal_base.base_container_v1.xml with the augmented property name, like so

...
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="minimal_base.base_container.v1_0_0">
            <Annotation Term="Redfish.OwningEntity" String="DMTF"/>
            <EntityType Name="base_container" BaseType="minimal_base.base_container.base_container">
                <Annotation Term="RedfishYang.NodeTypes" EnumMember="RedfishYang.NodeTypes/container"/>
                <Property Name="id" Type="RedfishYang.uint32">
                    <Annotation Term="RedfishYang.NodeTypes" EnumMember="RedfishYang.NodeTypes/leaf"/>
                    <Annotation Term="RedfishYang.YangType" String="uint32"/>
                    <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
                </Property>
                <Property Name="name" Type="Edm.String">
                    <Annotation Term="RedfishYang.NodeTypes" EnumMember="RedfishYang.NodeTypes/leaf"/>
                    <Annotation Term="RedfishYang.YangType" String="string"/>
                    <Annotation Term="OData.Permissions" EnumMember="OData.Permission/Read"/>
                </Property>
            </EntityType>
    </Schema>
...

Notably, the file for minimal_v1.xml is largely empty since it does not actually contain any payload content itself. This is from what I understand. Seems that this might prove an issue, as there's not really any way to know if a generated xml had been augmented.

tomasg2012 commented 6 years ago

@dorado18 Is this a satisfactory explanation?

dorado18 commented 6 years ago

Yes, it is! Thank you very much! I will close the issue.