Skip to content

Commit

Permalink
Merge pull request sonic-net#266 from pavel-shirshov/pavelsh/qos_file
Browse files Browse the repository at this point in the history
Render qos.json.j2 from a template
  • Loading branch information
pavel-shirshov authored Jun 21, 2018
2 parents a52ecd0 + f39cd9f commit 5baa305
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,19 @@ def reload():
if os.path.isfile(buffer_template_file):
command = "{} -m -t {} >/tmp/buffers.json".format(SONIC_CFGGEN_PATH, buffer_template_file)
run_command(command, display_cmd=True)
command = "{} -j /tmp/buffers.json --write-to-db".format(SONIC_CFGGEN_PATH)
run_command(command, display_cmd=True)
qos_file = os.path.join('/usr/share/sonic/device/', platform, hwsku, 'qos.json')
if os.path.isfile(qos_file):
command = "{} -j {} --write-to-db".format(SONIC_CFGGEN_PATH, qos_file)

qos_template_file = os.path.join('/usr/share/sonic/device/', platform, hwsku, 'qos.json.j2')
if os.path.isfile(qos_template_file):
command = "{} -m -t {} >/tmp/qos.json".format(SONIC_CFGGEN_PATH, qos_template_file)
run_command(command, display_cmd=True)

# Apply the configurations only when both buffer and qos configuration files are presented
command = "{} -j /tmp/buffers.json --write-to-db".format(SONIC_CFGGEN_PATH)
run_command(command, display_cmd=True)
command = "{} -j /tmp/qos.json --write-to-db".format(SONIC_CFGGEN_PATH)
run_command(command, display_cmd=True)
else:
click.secho('QoS definition not found at {}'.format(qos_file), fg='yellow')
click.secho('QoS definition template not found at {}'.format(qos_template_file), fg='yellow')
else:
click.secho('Buffer definition template not found at {}'.format(buffer_template_file), fg='yellow')

Expand Down

0 comments on commit 5baa305

Please sign in to comment.