You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CommonApp is a default app that handles the GET/SET/Subscribe requests for the YANG modules unless an app module is registered to Translib.
881
+
Please refer to [Management Framework HLD](https://github.com/sonic-net/SONiC/blob/master/doc/mgmt/Management%20Framework.md) for more details.
882
+
883
+
#### 3.3.1 CommonApp's TranslateSubscribe
884
+
885
+
The `TranslateSubscribe` interface will be implemented in the CommonApp to generically handle any given request path
886
+
to find the DB information and preferences mapped for this path.
887
+
This function will traverse the given request path to find and call the annotated key, table, and subscribe transformer
888
+
accordingly to translate the YANG key into DB table key, and discover the DB number, table name, key components, and fields for its
889
+
target node and all of its child nodes.
890
+
891
+
#### 3.3.2 CommonApp's ProcessSubscribe
892
+
893
+
The `ProcessSubscribe` interface will be implemented in the CommonApp to generically handle any given path
894
+
to resolve YANG keys for a given DB entry.
895
+
To resolve YANG keys, this function will traverse the given path to find and call its corresponding key, table, and path transformers.
896
+
If there is no mapped transformer for the given path, then the given DB table key will be used as it is to resolve the YANG keys.
897
+
898
+
### 3.4 Transformer
899
+
900
+
#### 3.4.1 Subtree Subscribe transformer
901
+
902
+
For the subtree annotated YANG path, `SubTreeXfmrSubscribe' transformer callback function should
903
+
handle the given path and all of its child node paths underneath and return the mapped DB number, table name,
904
+
key components, and fields for the target node of the path and all of its child node path accordingly.
905
+
906
+
```go
907
+
908
+
// SubTreeXfmrSubscribe type is defined to use for handling subscribe(translateSubscribe & processSubscribe)
// XfmrSubscInParams to represent the subscribe request info for the subtree path
913
+
type XfmrSubscInParams struct {
914
+
uri string// path of the subtree
915
+
dbs [db.MaxDB]*db.DB// DB structure pointers
916
+
subscProc SubscProcType // type of the subscription request
917
+
}
918
+
919
+
// XfmrSubscOutParams to represent the mapped DB info., and notification preferences
920
+
typeXfmrSubscOutParamsstruct {
921
+
dbDataMap RedisDbSubscribeMap// DB data map
922
+
secDbDataMap RedisDbYgNodeMap// to map the DB table for leaf or leaf-list node, if this table is different from its parent node's (container/list) table
923
+
onChange OnchangeMode// to enable or disable the ON_CHANGE mode
924
+
nOpts *notificationOpts // to mention the sample interval, and its type
925
+
isVirtualTbl bool// to specify if the DB tale is present or not
926
+
}
927
+
928
+
// notificationOpts to define sample interval time and notification preference type
929
+
type notificationOpts struct {
930
+
mInterval int// sample subscription interval time
931
+
pType NotificationType// to specify the notification preference types such as TARGET_DEFINED(default value), SAMPLE, ON_CHANGE.
932
+
}
933
+
934
+
```
935
+
936
+
#### 3.4.2 Path transformer
937
+
938
+
A new transformer annotation `sonic-ext:path-transformer <transformer-name>` will be defined to specify the path transformer name
939
+
to handle special cases --- subtree transformer or when there is no one-to-one mapping of YANG key to DB key.
940
+
941
+
A transformer callback function with name as specified in annotation must be defined in the transformer package inside the translib.
942
+
This transformer function will convert the given DB table key into YANG keys of all the list nodes present in the given YANG path and fill
943
+
these converted YANG keys in the given URI path by replacing the wildcard (*).
944
+
945
+
```go
946
+
947
+
// PathXfmrDbToYangFunc converts the given DB table key into the YANG key for all the list node in the given path.
0 commit comments