diff --git a/doc/mgmt/gnmi/SONiC_GNMI_Server_Interface_Design.md b/doc/mgmt/gnmi/SONiC_GNMI_Server_Interface_Design.md index d97234ba3a..23363f8428 100644 --- a/doc/mgmt/gnmi/SONiC_GNMI_Server_Interface_Design.md +++ b/doc/mgmt/gnmi/SONiC_GNMI_Server_Interface_Design.md @@ -164,7 +164,13 @@ The ultimate goal is to use SONiC Yang models for configuration, and we also nee * We will follow OpenConfig specification to use origin field to support mixed schema. -* And we use the first element to specify the target database. +* We use the first element to specify the target database. + +* We use the second element to specify the database instance: + * For single asic device, this element is "localhost" + * For multiple asic device, this element can be "localhost", "asic0", "asic1", ... + * For smartswitch device, this element can be "localhost", "dpu0", "dpu1", ... + * For smartswitch with multiple asic NPU, this element can be "localhost", "asic0", "asic1", ..., "dpu0", "dpu1", ... A single request cannot have both SONiC YANG paths and ConfigDB/ApplDB schema paths. @@ -214,7 +220,7 @@ With CONFIG_DB schema: ++++++++ Sending get request: ++++++++ path { - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} } encoding: JSON_IETF ++++++++ Recevied get response: ++++++++ @@ -222,7 +228,7 @@ With CONFIG_DB schema: update { path { origin: "sonic_db" - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} } val { json_ietf_val: "{\"name\": \"Servers1\",\"port\": \"eth0\"}" @@ -231,7 +237,7 @@ With CONFIG_DB schema: update { path { origin: "sonic_db" - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"} } val { json_ietf_val: "{\"name\": \"Servers23\",\"port\": \"eth0\"}" @@ -244,7 +250,7 @@ With CONFIG_YANG schema: ++++++++ Sending get request: ++++++++ path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} } encoding: JSON_IETF ++++++++ Recevied get response: ++++++++ @@ -252,7 +258,7 @@ With CONFIG_YANG schema: update { path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} } val { json_ietf_val: "{\"name\": \"Servers1\",\"port\": \"eth0\"}" @@ -261,7 +267,7 @@ With CONFIG_YANG schema: update { path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}} } val { json_ietf_val: "{\"name\": \"Servers23\",\"port\": \"eth0\"}" @@ -277,13 +283,13 @@ With CONFIG_DB schema: replace { path { origin: "sonic_db" - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"} } } replace { path { origin: "sonic_db" - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"} } val { json_ietf_val: "eth1" @@ -293,14 +299,14 @@ With CONFIG_DB schema: response { path { origin: "sonic_db" - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"} } op: REPLACE } response { path { origin: "sonic_db" - elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"} } op: REPLACE } @@ -311,13 +317,13 @@ With CONFIG_YANG schema: replace { path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}} } } replace { path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"} } val { json_ietf_val: "eth1" @@ -327,14 +333,14 @@ With CONFIG_YANG schema: response { path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet96"}} } op: REPLACE } response { path { origin: "sonic_yang" - elem {name: "CONFIG_DB"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"} + elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "sonic-device_neighbor:sonic-device_neighbor"} elem {name: "sonic-device_neighbor:DEVICE_NEIGHBOR"} elem {name: "DEVICE_NEIGHBOR_LIST" key {key: "name" value: "Ethernet8"}} elem {name: "port"} } op: REPLACE } @@ -364,7 +370,7 @@ Below table provides an example to translate from SetRequest to JsonPatch. ### Table 3: Translate Example | SetRequest Format | JsonPatch Format | | ---- | ---- | -| replace {
 path {
  elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
 }
}
replace {
 path {
  elem {name: "CONFIG_DB"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}
 }
 val { json_ietf_val: "eth1" }
} | [
 {
  "op": "remove", "path": "/DEVICE_NEIGHBOR/Ethernet96"},
  { "op": "add", "path": "/DEVICE_NEIGHBOR/Ethernet8/port", "value": "eth1"}
] | +| replace {
 path {
  elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet96"}
 }
}
replace {
 path {
  elem {name: "CONFIG_DB"} elem {name: "localhost"} elem {name: "DEVICE_NEIGHBOR"} elem {name: "Ethernet8"} elem {name: "port"}
 }
 val { json_ietf_val: "eth1" }
} | [
 {
  "op": "remove", "path": "/DEVICE_NEIGHBOR/Ethernet96"},
  { "op": "add", "path": "/DEVICE_NEIGHBOR/Ethernet8/port", "value": "eth1"}
] | #### 1.2.1.5 Full Configurations @@ -374,21 +380,33 @@ SetRequest message will be: ++++++++ Sending set request: ++++++++ delete { - path { origin: "sonic_db" } + path { + origin: "sonic_db" + elem {name: "CONFIG_DB"} elem {name: "localhost"} + } } update { - path { origin: "sonic_db" } + path { + origin: "sonic_db" + elem {name: "CONFIG_DB"} elem {name: "localhost"} + } val { json_ietf_val: "{\"DEVICE_NEIGHBOR/Ethernet8/name\":\"Servers1\", \"DEVICE_NEIGHBOR/Ethernet8/port\":\"eth0\", \"DEVICE_NEIGHBOR/Ethernet96/name\":\"Servers23\", \"DEVICE_NEIGHBOR/Ethernet96/port\":\"eth0\", ...}" } } ++++++++ Recevied set response: ++++++++ response { - path { origin: "sonic_db" } + path { + origin: "sonic_db" + elem {name: "CONFIG_DB"} elem {name: "localhost"} + } op: DELETE } response { - path { origin: "sonic_db" } + path { + origin: "sonic_db" + elem {name: "CONFIG_DB"} elem {name: "localhost"} + } op: UPDATE } @@ -454,27 +472,6 @@ The full configuration request will be overwritten by subsequent full configurat overwritten-config -#### 1.2.1.12 Backward Compatibility - -SONiC telemetry is using prefix target to identify target database, and we will add a new target to support mixed schema. - - enum Target { - option allow_alias = true; - APPL_DB = 0; - ASIC_DB = 1; - COUNTERS_DB = 2; - LOGLEVEL_DB = 3; - CONFIG_DB = 4; - // PFC_WD_DB shares the the same db number with FLEX_COUNTER_DB - PFC_WD_DB = 5; - FLEX_COUNTER_DB = 5; - STATE_DB = 6; - // For none-DB data - OTHERS = 100; - // For mixed schema - MIXED_SCHEMA = 101; - } - ### 1.2.2 Container diff --git a/doc/mgmt/gnmi/images/message_example.svg b/doc/mgmt/gnmi/images/message_example.svg index 36ad96e9c8..bc651e7d89 100644 --- a/doc/mgmt/gnmi/images/message_example.svg +++ b/doc/mgmt/gnmi/images/message_example.svg @@ -28,339 +28,344 @@ - + - - + + - + - + - + - + - + SetRequest Message - + - + @@ -409,217 +414,238 @@ - + - + - + - + delete { - + - + - + - + - + - + path { - + - + - + - + - + - + origin: " - + - + sonic_db - + - + " - + - + - + - + - + - + elem {name: “ - + - + CONFIG_DB - + - + ”} - + - - elem {name: + + elem {name: “ - + - - + localhost + + + + + + ”} + + + + + + elem {name: + + + + + + - + - + DEVICE_NEIGHBOR + x="0,57,102,154,177,225,270,316,375,420,443,501,558,607,668,718" y="0" + transform="translate(357,692)" xml:space="preserve">DEVICE_NEIGHBOR - + - - + - + - + } elem {name: + x="0,29,50,96,116,161,235,256,285,333,376,450,495,520,540" y="0" + transform="translate(1113,692)" xml:space="preserve">} elem {name: - + - - + - + - - Ethernet95 + + Ethernet95 - + - - + - + - - + } - + - - + - + - + - + - + } - + - + - + - + } - + - + @@ -656,548 +682,590 @@ - + - + - + - + replace { - + - + - + - + - + - + path { - + - + - + - + - + - + origin: " - + - + sonic - + - + _db" - + - + - + - + - + - + elem {name: “ - + - + CONFIG_DB - + - + ”} - + - - elem {name: + + elem {name: “ - + - - + localhost + + + + + + ”} + + + + + + elem {name: + + + + + + - + - + DEVICE_NEIGHBOR + x="0,57,102,154,177,225,270,316,375,420,443,501,558,607,668,718" y="0" + transform="translate(357,1732)" xml:space="preserve">DEVICE_NEIGHBOR - + - - + - + - - + } - + - - elem {name: + + elem {name: - + - - + - + - - Ethernet96 + + Ethernet96 - + - - + - + - - + } - + - - + - + - + - + - + } - + - + - + - + } - + - + - + - + replace { - + - + - + - + - + - + path { - + - + - + - + - + - + origin: - + - + “sonic - + - + _db" - + - + - + - + - + - + elem {name: “ - + - + CONFIG_DB - + - + ”} - + - - elem {name: + + elem {name: “ - + - - + localhost + + + + + + ”} + + + + + + elem {name: + + + + + + - + - + DEVICE_NEIGHBOR + x="0,57,102,154,177,225,270,316,375,420,443,501,558,607,668,718" y="0" + transform="translate(357,2515)" xml:space="preserve">DEVICE_NEIGHBOR - + - - + - + - - + } - + - - elem {name: + + elem {name: - + - - + - + - - Ethernet8 + + Ethernet8 - + - - + - + - + } elem {name: + x="0,28,49,95,116,161,235,256,285,333,376,450,495,520,540" y="0" + transform="translate(2103,2515)" xml:space="preserve">} elem {name: - + - - + - + - - port + + port - + - - + - + - - + } - + - - + - + - + - + - + } - + - + - + - + - + - + val { - + - + - + - + - + - + json_ietf_val: - + - + “e - + - + th1 - + - + - + - + - + - + - + - + } - + - + - + - + } - + - + @@ -1234,372 +1302,393 @@ - + - + - + - + update - + - + - + - + { - + - + - + - + - + - + path { - + - + - + - + - + - + origin: " - + - + sonic_db - + - + " - + - + - + - + - + - + elem {name: “ - + - + CONFIG_DB - + - + ”} - + - - elem {name: + + elem {name: “ - + - - + localhost + + + + + + ”} + + + + + + elem {name: + + + + + + - + - + DEVICE_NEIGHBOR + x="0,57,102,154,177,225,270,316,375,420,443,501,558,607,668,718" y="0" + transform="translate(357,4249)" xml:space="preserve">DEVICE_NEIGHBOR - + - - + - + - - + } - + - - + - + - - elem {name: + + elem {name: - + - - + - + - - Ethernet + + Ethernet - + - - + 9 - + - - + - + - + } elem {name: + x="0,28,49,95,116,161,235,256,285,333,376,450,495,520,540" y="0" + transform="translate(2103,4249)" xml:space="preserve">} elem {name: - + - - + - + - - port + + port - + - - + - + - - + } - + - - + - + - + - + - + } - + - + - + - + - + - + val { - + - + - + - + - + - + json_ietf_val: - + - + - + - + eth - + - + 2 - + - + - + - + - + - + - + - + } - + - + - + - + } - + - + @@ -1667,10 +1756,10 @@ - + - +