Skip to content

Commit 1565ba2

Browse files
author
Volodymyr Samotiy
authored
[crm] Use swsssdk API instead of redis-cli for getting keys from redis DB (sonic-net#943)
1 parent af42b55 commit 1565ba2

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

crm/main.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import click
44
import swsssdk
55
from tabulate import tabulate
6-
from subprocess import Popen, PIPE
76

87
class Crm:
98
def __init__(self):
@@ -123,15 +122,9 @@ def show_acl_table_resources(self):
123122
header = ("Table ID", "Resource Name", "Used Count", "Available Count")
124123

125124
# Retrieve all ACL table keys from CRM:ACL_TABLE_STATS
126-
# TODO
127-
# Volodymyr is working on refactoring codes to access redis database via redis-py or swsssdk
128-
# we should avoid using 'keys' operation via redis-cli or sonic-db-cli
129-
# there would be an issue when KEY in database contains space or '\n'
130-
# for loop on the non-tty 'keys' output will take the space or `\n` as seperator when parsing the element
131-
proc = Popen("docker exec -i database redis-cli --raw -n 2 KEYS *CRM:ACL_TABLE_STATS*", stdout=PIPE, stderr=PIPE, shell=True)
132-
out, err = proc.communicate()
133-
134-
for key in out.splitlines() or [None]:
125+
crm_acl_keys = countersdb.keys(countersdb.COUNTERS_DB, 'CRM:ACL_TABLE_STATS*')
126+
127+
for key in crm_acl_keys or [None]:
135128
data = []
136129

137130
if key:

0 commit comments

Comments
 (0)