Skip to content

Replace swsssdk with swsscommon in bgpmon.py #11387

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

Merged
merged 4 commits into from
Aug 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/sonic-bgpcfgd/bgpmon/bgpmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import json
import os
import syslog
import swsssdk
from swsscommon import swsscommon
import time

PIPE_BATCH_MAX_COUNT = 50
Expand All @@ -43,10 +43,8 @@ def __init__(self):
self.new_peer_l = set()
self.new_peer_state = {}
self.cached_timestamp = 0
self.db = swsssdk.SonicV2Connector()
self.db = swsscommon.SonicV2Connector()
self.db.connect(self.db.STATE_DB, False)
client = self.db.get_redis_client(self.db.STATE_DB)
self.pipe = client.pipeline()
self.db.delete_all_by_pattern(self.db.STATE_DB, "NEIGH_STATE_TABLE|*" )

# A quick way to check if there are anything happening within BGP is to
Expand Down Expand Up @@ -106,11 +104,10 @@ def flush_pipe(self, data):
for key, value in data.items():
if value is None:
# delete case
self.pipe.delete(key)
self.db.delete(self.db.STATE_DB, key)
else:
# Add or Modify case
self.pipe.hmset(key, value)
self.pipe.execute()
self.db.hmset(self.db.STATE_DB, key, value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will improve this code with pipe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will push a update to pipe improve PR, to make code easy here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, now this PR depends on sonic-net/sonic-swss-common#647
We need that PR finish and update submodule first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sonic-swss-common PR merged, create another PR to merge submodule: #11470

After that, this PR can pass UT.

data.clear()

def update_neigh_states(self):
Expand Down