Adding new Sonic Yang

207 views
Skip to first unread message

Shakti

unread,
Oct 28, 2021, 3:55:41 AM10/28/21
to sonic-mgmt-workgroup
Hi All,

I'm trying to add a new dummy Sonic yang model(for understanding purposes).
As I understand from the documentation, the following needs to be done:

- Define the Sonic yang model, as per the Sonic guidlines 
- Add corresponding test entry in sample_config_db.json (this test passes)

The conversion from yang to DB and vice-versa will be handled by common app.
(As done for sonic-port.yang)

Post these steps, I get the REST interface and yaml generated. 
But when I try to PUT/POST, although there is no error, the CONFIG DB doesn't gets updated.

YANG:
---------------
module sonic-myapp {
  prefix myapp;
  yang-version 1.1;
  organization "Dummy Org";
  contact "du...@dummy.com";
  description "Dummy Sonic YANG model";

  revision 2021-10-25 {
    description
      "Initial revision";
  }

  container sonic-myapp {
          description
                  "Dummy container";

          container MYAPP_TABLE {
                container myapp_first {

                  leaf myapp_leaf {
                          type string;
                          default "dummy";
                  }
                }
          }
  }
}

Probable Issue:
--------------------------
common_app.go:377] XlatetoDB() returned empty map
db.go:1209] StartTx: Begin: w: [] tss: []
db.go:1299] performWatch: Empty WatchKeys. Skipping WATCH
db.go:1233] StartTx: End: e: <nil>
common_app.go:223] processReplace:path =/sonic-myapp:sonic-myapp/MYAPP_TABLE/myapp_first/myapp_leaf
db.go:1321] CommitTx: Begin:
db.go:1334] CommitTx: No SET|DEL done, txState: txStateWatch
db.go:456] ts2redisUpdated: Begin: *
db.go:1458] CommitTx: End: e: <nil>
db.go:418] DeleteDB: Begin: d: { client: Redis<127.0.0.1:6379 db:4>, Opts: { DBNo: 4, InitIndicator: , TableNameSeparator: |, KeySeparator: | , DisableCVLCheck: false }, txState: txStateNone, tsCmds: [] }
handler.go:72] [REST-1] Sending response 204, type=, data=
router.go:128] [REST-1] PutSonicMyappSonicMyappMyappTableMyappFirstMyappLeaf took 11.098038ms


Request any pointers on the same.
Do I need to write an application.go for handling the CRUD operations? 
(which as of now I assume is needed only for non sonic yangs).

Regards


Anand Kumar Subramanian

unread,
Nov 1, 2021, 5:34:06 PM11/1/21
to Shakti, sonic-mgmt-workgroup
Hi Shakti,

Seems your sonic yang list name is not right.
Please refer to the sonic yang guidelines point 5 in the link below.


module sonic-myapp {
  prefix myapp;
  yang-version 1.1;
  organization "Dummy Org";
  contact "du...@dummy.com";
  description "Dummy Sonic YANG model";

  revision 2021-10-25 {
    description
      "Initial revision";
  }

  container sonic-myapp {
          description
                  "Dummy container";

          container MYAPP_TABLE {
                container myapp_first { //This has to be a list and also name has to be MYAPP_TABLE_LIST

                  leaf myapp_leaf {
                          type string;
                          default "dummy";
                  }
                }
          }
  }
}

-Anand

STL - Sterlite Technologies Limited Disclaimer:
The content of this message may be legally privileged and confidential and are for the use of the intended recipient(s) only. It should not be read, copied and used by anyone other than the intended recipient(s). If you have received this message in error, please immediately notify the sender, preserve its confidentiality and delete it. Before opening any attachments please check them for viruses and defects. No employee or agent is authorised to conclude any binding agreement on behalf of Sterlite Technologies Limited with another party by email without express written confirmation by authorised personVisit us at www.stl.tech
 Please consider environment before printing this email !

Registered office: E 1, MIDC Industrial Area, Waluj, Aurangabad, Maharashtra – 431 136 CIN – L31300MH2000PLC269261

--
You received this message because you are subscribed to the Google Groups "sonic-mgmt-workgroup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonic-mgmt-workg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonic-mgmt-workgroup/b3273631-ccad-445e-8e78-ec46fa9297bdn%40googlegroups.com.

This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.

Shakti

unread,
Nov 3, 2021, 5:49:12 AM11/3/21
to sonic-mgmt-workgroup
Thanks Anand, it worked.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages