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

Add opcode for notification in configdb.py #41

Open
batmancn opened this issue Nov 27, 2018 · 0 comments
Open

Add opcode for notification in configdb.py #41

batmancn opened this issue Nov 27, 2018 · 0 comments

Comments

@batmancn
Copy link

batmancn commented Nov 27, 2018

Hi all,

I think it's good to add opcode for notification in configdb.py to verify the difference between these:

"AAA": null
"AAA": {}

So I want to contribute a PR with this patch as bellow, but I have no access for push and merge PR? How to deal with this?

commit f547f9c02347e7b42962278005bcba973892a18b
Author: sam <[email protected]>
Date:   Tue Nov 27 11:31:27 2018 +0800

    add opcode in redis notification

diff --git a/src/swsssdk/configdb.py b/src/swsssdk/configdb.py
index e255979..87cad6e 100644
--- a/src/swsssdk/configdb.py
+++ b/src/swsssdk/configdb.py
@@ -76,10 +76,10 @@ class ConfigDBConnector(SonicV2Connector):
         if self.handlers.has_key(table):
             self.handlers.pop(table)

-    def __fire(self, table, key, data):
+    def __fire(self, table, key, data, op_str='add'):
         if self.handlers.has_key(table):
             handler = self.handlers[table]
-            handler(table, key, data)
+            handler(table, key, data, op_str)

     def listen(self):
         """Start listen Redis keyspace events and will trigger corresponding handlers when content of a table changes.
@@ -94,7 +94,11 @@ class ConfigDBConnector(SonicV2Connector):
                     if self.handlers.has_key(table):
                         client = self.redis_clients[self.CONFIG_DB]
                         data = self.__raw_to_typed(client.hgetall(key))
-                        self.__fire(table, row, data)
+                        op = client.keys(key)
+                        op_str = 'add'
+                        if len(op) == 0:
+                            op_str = 'del'
+                        self.__fire(table, row, data, op_str)
                 except ValueError:
                     pass    #Ignore non table-formated redis entries
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

No branches or pull requests

1 participant