CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Fix ydk-gen to handle multiple augments #922

Closed ghost closed 5 years ago

ghost commented 5 years ago

Need to port the below commit to 0.5.5.m1 branch

https://github.com/CiscoDevNet/ydk-gen/commit/457e0a1e5349cc1272230ee827526e7ba44c1f6c#diff-bb7baa2588e0d9825fbfee3ac3cca2b4

ghost commented 5 years ago

After fix

Generated API now looks like:


        .. attribute:: cisco_ios_xr_um_mpls_te_cfg_logging

            Per\-interface logging configuration
            **type**\:   :py:class:`CiscoIosXrUmMplsTeCfg_Logging <ydk.models.cisco_iosxr_701.Cisco_IOS_XR_um_interface_cfg.Interfaces.Interface.CiscoIosXrUmMplsTeCfg_Logging>`

        .. attribute:: logging

            Per\-interface logging configuration
            **type**\:   :py:class:`Logging <ydk.models.cisco_iosxr_701.Cisco_IOS_XR_um_interface_cfg.Interfaces.Interface.Logging>`

For script:

from ydk.models.cisco_iosxr_701 import Cisco_IOS_XR_um_interface_cfg as y1 

from ydk.services import CodecService 
from ydk.providers import CodecServiceProvider 

codec = CodecService() 
codec_p = CodecServiceProvider(type="xml") 

i_fs = y1.Interfaces() 
i_f = i_fs.Interface() 
i_f.name = 'GigabitEthernet 0/0/0/0'
i_f.logging.events.link_status = i_f.logging.events.LinkStatus() 
i_f.cisco_ios_xr_um_mpls_te_cfg_logging.events.bfd_status = i_f.cisco_ios_xr_um_mpls_te_cfg_logging.events.BfdStatus() 
i_fs.interface.append(i_f)
print(codec.encode(codec_p, i_fs))

Payload looks like below

<interfaces xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-interface-cfg">
  <interface>
    <logging xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-mpls-te-cfg">
      <events>
        <bfd-status/>
      </events>
    </logging>
    <logging>
      <events>
        <link-status/>
      </events>
    </logging>
  </interface>
</interfaces>