Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read full config with gnmi get #143

Merged
merged 10 commits into from
Aug 21, 2023
Merged

Conversation

ganglyu
Copy link
Contributor

@ganglyu ganglyu commented Aug 15, 2023

Why I did it

Need to read full config for SONiC

How I did it

Read CONFIG DB and convert to json.

How to verify it

Verified with unit test and end2end test.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@@ -337,7 +337,9 @@ func (c *MixedDbClient) populateDbtablePath(path *gnmipb.Path, value *gnmipb.Typ

tblPath.dbNamespace = dbNamespace
tblPath.dbName = targetDbName
tblPath.tableName = stringSlice[1]
if len(stringSlice) > 1 {
Copy link
Collaborator

@qiluo-msft qiluo-msft Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringSlice

Suggest move together the code related to len(stringSlice) and tableName. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

// Did no provide table name
// Get all tables in the DB
if tblPath.dbName == "COUNTERS_DB" {
return fmt.Errorf("Can not read all tables in COUNTERS_DB")
Copy link
Collaborator

@qiluo-msft qiluo-msft Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can not

This is interesting limitation. Is there a reason? Is it in any design doc? Or just not implemented today. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tables in COUNTERS_DB other than COUNTERS table doesn't have keys.
So, I prefer not to implement it today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have Added TODO and new unit test.

@@ -430,7 +434,9 @@ func (c *MixedDbClient) makeJSON_redis(msi *map[string]interface{}, key *string,
// TODO: Use Yang model to identify leaf-list
if key == nil && op == nil {
for f, v := range mfv {
if strings.HasSuffix(f, "@") {
if f == "NULL" {
continue
Copy link
Collaborator

@qiluo-msft qiluo-msft Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to understand the new branch. Could you add some code comment? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@avl-dev
Copy link

avl-dev commented Aug 17, 2023

Can template like "/*" be the part solution?

gnmi_get ... -xpath "/sonic-db:CONFIG_DB/*"

It will get all the fields but suddenly (bug or feature) delete table keys (like PORT, FLEX_COUNTER_TABLE etc.).

So, for example, all Ethernet ports from PORT are in same area with other keys:
(example of output from gnmic cli command, same with gnmi_get)

[
{
"source": "10.199.199.205:50051",
"timestamp": 1692108429229533512,
"time": "2023-08-15T14:07:09.229533512Z",
"target": "CONFIG_DB",
"updates": [
{
"Path": "*",
"values": {
"*": {
"ACL": {
"FLEX_COUNTER_DELAY_STATUS": "false",
"FLEX_COUNTER_STATUS": "disable",
"POLL_INTERVAL": "10000"
},
"BUFFER_POOL_WATERMARK": {
"FLEX_COUNTER_DELAY_STATUS": "false",
"FLEX_COUNTER_STATUS": "enable"
},
"Config": {
"acl_counter_high_threshold": "85",
"acl_counter_low_threshold": "70",
"acl_counter_threshold_type": "percentage",
"acl_entry_high_threshold": "85",
"acl_entry_low_threshold": "70",
"acl_entry_threshold_type": "percentage",
"acl_group_high_threshold": "85",
"acl_group_low_threshold": "70",
"acl_group_threshold_type": "percentage",
"acl_table_high_threshold": "85",
"acl_table_low_threshold": "70",
"acl_table_threshold_type": "percentage",
"dnat_entry_high_threshold": "85",
"dnat_entry_low_threshold": "70",
"dnat_entry_threshold_type": "percentage",
"fdb_entry_high_threshold": "85",
"fdb_entry_low_threshold": "70",
"fdb_entry_threshold_type": "percentage",
"ipmc_entry_high_threshold": "85",
"ipmc_entry_low_threshold": "70",
"ipmc_entry_threshold_type": "percentage",
"ipv4_neighbor_high_threshold": "85",
"ipv4_neighbor_low_threshold": "70",
"ipv4_neighbor_threshold_type": "percentage",
"ipv4_nexthop_high_threshold": "85",
"ipv4_nexthop_low_threshold": "70",
"ipv4_nexthop_threshold_type": "percentage",
"ipv4_route_high_threshold": "85",
"ipv4_route_low_threshold": "70",
"ipv4_route_threshold_type": "percentage",
"ipv6_neighbor_high_threshold": "85",
"ipv6_neighbor_low_threshold": "70",
"ipv6_neighbor_threshold_type": "percentage",
"ipv6_nexthop_high_threshold": "85",
"ipv6_nexthop_low_threshold": "70",
"ipv6_nexthop_threshold_type": "percentage",
"ipv6_route_high_threshold": "85",
"ipv6_route_low_threshold": "70",
"ipv6_route_threshold_type": "percentage",
"mpls_inseg_high_threshold": "85",
"mpls_inseg_low_threshold": "70",
"mpls_inseg_threshold_type": "percentage",
"mpls_nexthop_high_threshold": "85",
"mpls_nexthop_low_threshold": "70",
"mpls_nexthop_threshold_type": "percentage",
"nexthop_group_high_threshold": "85",
"nexthop_group_low_threshold": "70",
"nexthop_group_member_high_threshold": "85",
"nexthop_group_member_low_threshold": "70",
"nexthop_group_member_threshold_type": "percentage",
"nexthop_group_threshold_type": "percentage",
"polling_interval": "300",
"snat_entry_high_threshold": "85",
"snat_entry_low_threshold": "70",
"snat_entry_threshold_type": "percentage"
},
"DATABASE": {
"VERSION": "version_4_0_2"
},
"Ethernet0": {
"admin_status": "up",
"alias": "fortyGigE0/0",
"index": "0",
"lanes": "25,26,27,28",
"mtu": "9100",
"speed": "40000"
},
"Ethernet100": {
"admin_status": "up",
"alias": "fortyGigE0/100",
"index": "25",
"lanes": "121,122,123,124",
"mtu": "9100",
"speed": "40000"
},
"Ethernet104": {
"admin_status": "up",
"alias": "fortyGigE0/104",
"index": "26",
"lanes": "81,82,83,84",
"mtu": "9100",
"speed": "40000"
},
...

So up here: ACL and BUFFER_POOL_WATERMARK – are from FLEX_COUNTER_TABLE; Ethernet* – from PORT; "config" – from CRM.

I see kind of solution to run multiple get request with different tables like "/sonic-db:CONFIG_DB/PORT", "/sonic-db:CONFIG_DB/CRM", "/sonic-db:CONFIG_DB/FLEX_COUNTER_TABLE" and so on. And then aggregate these data in one JSON file.

@ganglyu
Copy link
Contributor Author

ganglyu commented Aug 18, 2023

Can template like "/*" be the part solution?

gnmi_get ... -xpath "/sonic-db:CONFIG_DB/*"

It will get all the fields but suddenly (bug or feature) delete table keys (like PORT, FLEX_COUNTER_TABLE etc.).

So, for example, all Ethernet ports from PORT are in same area with other keys: (example of output from gnmic cli command, same with gnmi_get)

[
{
"source": "10.199.199.205:50051",
"timestamp": 1692108429229533512,
"time": "2023-08-15T14:07:09.229533512Z",
"target": "CONFIG_DB",
"updates": [
{
"Path": "",
"values": {
"
": {
"ACL": {
"FLEX_COUNTER_DELAY_STATUS": "false",
"FLEX_COUNTER_STATUS": "disable",
"POLL_INTERVAL": "10000"
},
"BUFFER_POOL_WATERMARK": {
"FLEX_COUNTER_DELAY_STATUS": "false",
"FLEX_COUNTER_STATUS": "enable"
},
"Config": {
"acl_counter_high_threshold": "85",
"acl_counter_low_threshold": "70",
"acl_counter_threshold_type": "percentage",
"acl_entry_high_threshold": "85",
"acl_entry_low_threshold": "70",
"acl_entry_threshold_type": "percentage",
"acl_group_high_threshold": "85",
"acl_group_low_threshold": "70",
"acl_group_threshold_type": "percentage",
"acl_table_high_threshold": "85",
"acl_table_low_threshold": "70",
"acl_table_threshold_type": "percentage",
"dnat_entry_high_threshold": "85",
"dnat_entry_low_threshold": "70",
"dnat_entry_threshold_type": "percentage",
"fdb_entry_high_threshold": "85",
"fdb_entry_low_threshold": "70",
"fdb_entry_threshold_type": "percentage",
"ipmc_entry_high_threshold": "85",
"ipmc_entry_low_threshold": "70",
"ipmc_entry_threshold_type": "percentage",
"ipv4_neighbor_high_threshold": "85",
"ipv4_neighbor_low_threshold": "70",
"ipv4_neighbor_threshold_type": "percentage",
"ipv4_nexthop_high_threshold": "85",
"ipv4_nexthop_low_threshold": "70",
"ipv4_nexthop_threshold_type": "percentage",
"ipv4_route_high_threshold": "85",
"ipv4_route_low_threshold": "70",
"ipv4_route_threshold_type": "percentage",
"ipv6_neighbor_high_threshold": "85",
"ipv6_neighbor_low_threshold": "70",
"ipv6_neighbor_threshold_type": "percentage",
"ipv6_nexthop_high_threshold": "85",
"ipv6_nexthop_low_threshold": "70",
"ipv6_nexthop_threshold_type": "percentage",
"ipv6_route_high_threshold": "85",
"ipv6_route_low_threshold": "70",
"ipv6_route_threshold_type": "percentage",
"mpls_inseg_high_threshold": "85",
"mpls_inseg_low_threshold": "70",
"mpls_inseg_threshold_type": "percentage",
"mpls_nexthop_high_threshold": "85",
"mpls_nexthop_low_threshold": "70",
"mpls_nexthop_threshold_type": "percentage",
"nexthop_group_high_threshold": "85",
"nexthop_group_low_threshold": "70",
"nexthop_group_member_high_threshold": "85",
"nexthop_group_member_low_threshold": "70",
"nexthop_group_member_threshold_type": "percentage",
"nexthop_group_threshold_type": "percentage",
"polling_interval": "300",
"snat_entry_high_threshold": "85",
"snat_entry_low_threshold": "70",
"snat_entry_threshold_type": "percentage"
},
"DATABASE": {
"VERSION": "version_4_0_2"
},
"Ethernet0": {
"admin_status": "up",
"alias": "fortyGigE0/0",
"index": "0",
"lanes": "25,26,27,28",
"mtu": "9100",
"speed": "40000"
},
"Ethernet100": {
"admin_status": "up",
"alias": "fortyGigE0/100",
"index": "25",
"lanes": "121,122,123,124",
"mtu": "9100",
"speed": "40000"
},
"Ethernet104": {
"admin_status": "up",
"alias": "fortyGigE0/104",
"index": "26",
"lanes": "81,82,83,84",
"mtu": "9100",
"speed": "40000"
},
...

So up here: ACL and BUFFER_POOL_WATERMARK – are from FLEX_COUNTER_TABLE; Ethernet* – from PORT; "config" – from CRM.

I see kind of solution to run multiple get request with different tables like "/sonic-db:CONFIG_DB/PORT", "/sonic-db:CONFIG_DB/CRM", "/sonic-db:CONFIG_DB/FLEX_COUNTER_TABLE" and so on. And then aggregate these data in one JSON file.

We will support wildcard in the future.

@ganglyu ganglyu merged commit fdb94da into sonic-net:master Aug 21, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants