Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ def get_command(self, ctx, cmd_name):
# location (configdb?), so that we prevent the continous execution of this
# bash oneliner. To be revisited once routing-stack info is tracked somewhere.
def get_routing_stack():
cmd0 = ["sudo", "docker", "ps"]
cmd1 = ["grep", "bgp"]
cmd2 = ["awk", '{print$2}']
cmd3 = ["cut", "-d-", "-f3"]
cmd4 = ["cut", "-d:", "-f1"]
result = 'frr'

cmd0 = ["sudo", "docker", "ps", "--format", "{{.Image}}\t{{.Names}}"]
cmd1 = ["awk", '$2 == "bgp"']
cmd2 = ["cut", "-d-", "-f3"]
cmd3 = ["cut", "-d:", "-f1"]
cmd4 = ["head", "-n", "1"]

try:
_, result = getstatusoutput_noshell_pipe(cmd0, cmd1, cmd2, cmd3, cmd4)

except OSError as e:
raise OSError("Cannot detect routing-stack")

return (result)


# Global Routing-Stack variable
routing_stack = get_routing_stack()

Expand Down
4 changes: 2 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
# location (configdb?), so that we prevent the continous execution of this
# bash oneliner. To be revisited once routing-stack info is tracked somewhere.
def get_routing_stack():
result = None
command = "sudo docker ps | grep bgp | awk '{print$2}' | cut -d'-' -f3 | cut -d':' -f1 | head -n 1"
result = 'frr'
command = "sudo docker ps --format '{{.Image}}\t{{.Names}}' | awk '$2 == \"bgp\"' | cut -d'-' -f3 | cut -d':' -f1 | head -n 1" # noqa: E501

try:
stdout = subprocess.check_output(command, shell=True, text=True, timeout=COMMAND_TIMEOUT)
Expand Down
Loading