Skip to content

Commit 9715244

Browse files
Separated the notifications for "sonic-clear nat translations" and "sonic-clear nat statistics" command (#892)
Signed-off-by: Akhilesh Samineni <[email protected]>
1 parent 7c512f3 commit 9715244

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

scripts/natclear

+11-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ class NatClear(object):
2323
self.db.connect(self.db.APPL_DB)
2424
return
2525

26-
def send_notification(self, op, data):
26+
def send_entries_notification(self, op, data):
2727
opdata = [op,data]
2828
msg = json.dumps(opdata,separators=(',',':'))
29-
self.db.publish('APPL_DB','FLUSHNATREQUEST', msg)
29+
self.db.publish('APPL_DB','FLUSHNATENTRIES', msg)
3030
return
3131

32+
def send_statistics_notification(self, op, data):
33+
opdata = [op,data]
34+
msg = json.dumps(opdata,separators=(',',':'))
35+
self.db.publish('APPL_DB','FLUSHNATSTATISTICS', msg)
36+
return
37+
38+
3239
def main():
3340
parser = argparse.ArgumentParser(description='Clear the nat information',
3441
formatter_class=argparse.RawTextHelpFormatter,
@@ -49,11 +56,11 @@ def main():
4956
try:
5057
nat = NatClear()
5158
if clear_translations:
52-
nat.send_notification("ENTRIES", "ALL")
59+
nat.send_entries_notification("ENTRIES", "ALL")
5360
print ""
5461
print("Dynamic NAT entries are cleared.")
5562
elif clear_statistics:
56-
nat.send_notification("STATISTICS", "ALL")
63+
nat.send_statistics_notification("STATISTICS", "ALL")
5764
print ""
5865
print("NAT statistics are cleared.")
5966
except Exception as e:

scripts/natshow

+8-2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class NatShow(object):
132132
continue
133133

134134
ip_protocol = "all"
135+
source = "---"
136+
destination = "---"
135137
translated_dst = "---"
136138
translated_src = "---"
137139

@@ -249,7 +251,7 @@ class NatShow(object):
249251
napt_keys = re.split(':', napt_entry)
250252
napt_values = self.appl_db.get_all(self.appl_db.APPL_DB,'NAPT_TABLE:{}'.format(napt_entry))
251253

252-
ip_protocol = napt_keys[0]
254+
ip_protocol = napt_keys[0].lower()
253255
source = "---"
254256
destination = "---"
255257

@@ -278,6 +280,8 @@ class NatShow(object):
278280
nat_twice_values = self.appl_db.get_all(self.appl_db.APPL_DB,'NAT_TWICE_TABLE:{}'.format(nat_twice_entry))
279281

280282
ip_protocol = "all"
283+
source = "---"
284+
destination = "---"
281285

282286
source = nat_twice_keys[0]
283287
destination = nat_twice_keys[1]
@@ -301,7 +305,9 @@ class NatShow(object):
301305
napt_twice_keys = re.split(':', napt_twice_entry)
302306
napt_twice_values = self.appl_db.get_all(self.appl_db.APPL_DB,'NAPT_TWICE_TABLE:{}'.format(napt_twice_entry))
303307

304-
ip_protocol = napt_twice_keys[0]
308+
ip_protocol = napt_twice_keys[0].lower()
309+
source = "---"
310+
destination = "---"
305311

306312
source = napt_twice_keys[1] + ':' + napt_twice_keys[2]
307313
destination = napt_twice_keys[3] + ':' + napt_twice_keys[4]

0 commit comments

Comments
 (0)