Skip to content

How to add extended yang function for Openconfig Yang? #60

@guangjung

Description

@guangjung

[Question] I tried to add extended yang for an Openconfig Yang, but found that leaf in extended yang cannot be operated (set/get operations by executing REST command). Can you make an example ? Or help me, thanks.

I met some questions, the steps are as follows:

  1. add yang files
    models/yang/openconfig-optical-attenuator.yang (Openconfig Yang, refer to attach file)
    models/yang/extensions/openconfig-optical-attenuator-ext.yang (customer extended yang, refer to attach file)
    models/yang/annotations/openconfig-optical-attenuator-annot.yang (annotation yang, refer to attach file)
    models/yang/sonic/sonic-optical-attenuator.yang
  2. add common transform handlers( eg. xfmr_optical.go)
  3. execute REST command by curl on device
    curl -vk -X POST --data-binary "@create_voa2.txt" "https://127.0.0.1/restconf/data/openconfig-optical-attenuator:optical-attenuator" -H "Content-Type: application/yang-data+json"

Result : test-bool value is not set to redis db, and an error occures in syslog:
Jul 28 03:16:50.993116 sonic INFO mgmt-framework#/supervisord: rest-server W0728 03:16:50.992765 19 xlate_to_db.go:94] Table for yang-path("/openconfig-optical-attenuator:optical-attenuator/attenuators/attenuator/config/test-bool") not found.

  1. I found some abnormal items in /tmp/fullSpec.txt (mgnt-framwork container) , refer to fullSpec.txt
    a. NOT find test-bool in yangEntry map of /openconfig-optical-attenuator:optical-attenuator/attenuators/attenuator/config
    b. tableName , yangEntry, keyXpath are empty in /openconfig-optical-attenuator:optical-attenuator/attenuators/attenuator/config/test-bool, but be OK in /openconfig-optical-attenuator:optical-attenuator/attenuators/attenuator/config/enabled
    why? How to modify openconfig-optical-attenuator-annot.yang or others in order to identify openconfig-optical-attenuator-ext.yang ?

fullSpec.txt
[openconfig-optical-attenuator-annot.yan
create_voa2.txt
g.txt](https://github.com/sonic-net/sonic-mgmt-common/files/9207507/openconfig-optical-attenuator-annot.yang.txt)
[openconfig-optical-attenuator-ext.yang.t
openconfig-optical-attenuator.yang.txt
xt](https://github.com/sonic-net/sonic-mgmt-common/files/9207519/openconfig-optical-attenuator-ext.yang.txt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions