Skip to content

Commit

Permalink
[yang_models]: Update extension yang and types yang with new yang ext… (
Browse files Browse the repository at this point in the history
#6861)

* [yang_models]: Update extension yang and types yang with new yang extensions and types respectively.
* [YANG] Added CVL specific type and moved sonic-types to j2 template.
  • Loading branch information
maheshwari-mayank authored Nov 23, 2021
1 parent 368b038 commit 5f235a9
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/sonic-yang-models/yang-models/sonic-breakout_cfg.yang
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module sonic-breakout_cfg {

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

description "BREAKOUT_CFG YANG Module for SONiC OS";
Expand Down
1 change: 0 additions & 1 deletion src/sonic-yang-models/yang-models/sonic-crm.yang
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module sonic-crm {

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

description "CRM YANG Module for SONiC OS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module sonic-device_metadata {

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

description "DEVICE_METADATA YANG Module for SONiC OS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module sonic-device_neighbor {

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

import sonic-port {
Expand Down
13 changes: 0 additions & 13 deletions src/sonic-yang-models/yang-models/sonic-extension.yang

This file was deleted.

2 changes: 0 additions & 2 deletions src/sonic-yang-models/yang-models/sonic-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ module sonic-interface {

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

import sonic-port {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ module sonic-loopback-interface {

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

import sonic-vrf {
Expand Down
2 changes: 0 additions & 2 deletions src/sonic-yang-models/yang-models/sonic-port.yang
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ module sonic-port{

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

description "PORT yang Module for SONiC OS";
Expand Down
4 changes: 1 addition & 3 deletions src/sonic-yang-models/yang-models/sonic-portchannel.yang
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ module sonic-portchannel {

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

import sonic-port {
Expand Down Expand Up @@ -138,7 +136,7 @@ module sonic-portchannel {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
}

leaf port {
/* key elements are mandatory by default */
type leafref {
Expand Down
2 changes: 0 additions & 2 deletions src/sonic-yang-models/yang-models/sonic-vlan.yang
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ module sonic-vlan {

import sonic-types {
prefix stypes;
revision-date 2019-07-01;
}

import sonic-extension {
prefix ext;
revision-date 2019-07-01;
}

import sonic-port {
Expand Down
41 changes: 41 additions & 0 deletions src/sonic-yang-models/yang-templates/sonic-extension.yang.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module sonic-extension {

yang-version 1.1;

namespace "http://github.com/Azure/sonic-extension";
prefix sonic-extension;

description "Extension yang Module for SONiC OS";

revision 2019-07-01 {
description "First Revision";
}

/* For complete guide of using these extensions in SONiC yangs, refer
SONiC yang guidelines at
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md */

extension db-name {
description "DB name, e.g. APPL_DB, CONFIG_DB";
argument "value";
}

{% if yang_model_type == "cvl" %}
extension custom-validation-cvl {
description "Extension for registering cvl based custom validation handler.";
argument "handler";
}

extension dependent-on {
description
"Extension to define dependency on other table. During CREATE/UPDATE,
the action will be performed first on the Parent table and then on the
Dependent table. In DELETE operation, the Dependent table will be
deleted first and then the Parent table. This extension can be defined
only under List nodes. Table name should always be suffixed with '_LIST'
as modeled in yang. e.g. - dependent-on STP_LIST";
argument "value";
}
{% else %}
{% endif %}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,42 @@ module sonic-types {
}
}

typedef oper-status {
type enumeration {
enum unknown;
enum up;
enum down;
}
description "Operational status of an entity such as Port, MCLAG etc";
}

typedef mode-status {
type enumeration {
enum enable;
enum disable;
}
description
"This type can be used where toggle functionality required.
For ex. IPv6-link-local-only, Dhcp-replay-link-select, SNMP traps etc";
}

typedef dhcp-relay-policy-action {
type enumeration {
enum discard;
enum append;
enum replace;
}
description "DHCP relay policy action value";
}

typedef percentage {
type uint8 {
range "0..100";
}
description
"Integer indicating a percentage value";
}

typedef tpid_type {
type string {
pattern "0x8100|0x9100|0x9200|0x88a8|0x88A8";
Expand Down Expand Up @@ -185,4 +221,27 @@ module sonic-types {
enum transit;
}
}



/* Required for CVL */
{% if yang_model_type == "cvl" %}
container operation {
description
"This definition is used internally by CVL and
is not exposed in NBI. Leaf 'operation' allows
evaluation of must expression for
CREATE/UPDATE/DELETE operation.";

leaf operation {
type enumeration {
enum NOP;
enum CREATE;
enum UPDATE;
enum DELETE;
}
}
}
{% else %}
{% endif %}
}

0 comments on commit 5f235a9

Please sign in to comment.