Skip to content

Commit

Permalink
handle enable shell, wrapper for swssconfig from config
Browse files Browse the repository at this point in the history
  • Loading branch information
banagiri committed Oct 1, 2020
1 parent 3e52604 commit 654aed1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3534,6 +3534,36 @@ def delete(ctx):

sflow_tbl['global'].pop('agent_id')
config_db.set_entry('SFLOW', 'global', sflow_tbl['global'])
@config.group(cls=AbbreviationGroup)
@click.pass_context
def switch(ctx):
"""switch related config"""
pass

@switch.command('shell')
@click.pass_context
@click.argument('en', metavar='<en>', required=True, type=int)
def set_sdk_diag_shell(ctx, en):
tmp_file = "/tmp/swss.json"
json_file = "/etc/swss/config.d/switch.json"
command = " docker cp swss:" + json_file + " " + tmp_file

proc = subprocess.Popen(command, shell=True)
import json
with open (tmp_file) as f:
cfg = json.load(f)

cfg[0]["SWITCH_TABLE:switch"]["sdk_diag_shell"] = en

with open (tmp_file, "w") as f:
json.dump(cfg,f,indent=4, ensure_ascii=False)

command = " docker cp " + tmp_file +" "+ "swss:"+json_file
proc = subprocess.Popen(command, shell=True)

command = "docker exec swss swssconfig " + json_file
proc = subprocess.Popen(command, shell=True)
(out, err) = proc.communicate()

if __name__ == '__main__':
config()

0 comments on commit 654aed1

Please sign in to comment.