Skip to content

Commit

Permalink
[config] Update SONiC Environment Vars Whne Loading Minigraph (sonic-…
Browse files Browse the repository at this point in the history
…net#1073)

Update SONiC envvars file when loading minigraph.

signed-off-by: Tamer Ahmed <[email protected]>
  • Loading branch information
tahmed-dev authored Aug 26, 2020
1 parent e18252e commit 5b916ab
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,24 @@ def validate_mirror_session_config(config_db, session_name, dst_port, src_port,

return True

def update_sonic_environment():
"""Prepare sonic environment variable using SONiC environment template file.
"""
SONIC_ENV_TEMPLATE_FILE = os.path.join('/', "usr", "share", "sonic", "templates", "sonic-environment.j2")
SONIC_VERSION_YML_FILE = os.path.join('/', "etc", "sonic", "sonic_version.yml")
SONIC_ENV_FILE = os.path.join('/', "etc", "sonic", "sonic-environment")

if os.path.isfile(SONIC_ENV_TEMPLATE_FILE) and os.path.isfile(SONIC_VERSION_YML_FILE):
clicommon.run_command(
"{} -d -y {} -t {},{}".format(
SONIC_CFGGEN_PATH,
SONIC_VERSION_YML_FILE,
SONIC_ENV_TEMPLATE_FILE,
SONIC_ENV_FILE
),
display_cmd=True
)

# This is our main entrypoint - the main 'config' command
@click.group(cls=clicommon.AbbreviationGroup, context_settings=CONTEXT_SETTINGS)
@click.pass_context
Expand Down Expand Up @@ -1219,6 +1237,9 @@ def load_minigraph(db, no_service_restart):
if device_type != 'MgmtToRRouter':
clicommon.run_command('{}pfcwd start_default'.format(ns_cmd_prefix), display_cmd=True)

# Update SONiC environmnet file
update_sonic_environment()

if os.path.isfile('/etc/sonic/acl.json'):
clicommon.run_command("acl-loader update full /etc/sonic/acl.json", display_cmd=True)

Expand Down

0 comments on commit 5b916ab

Please sign in to comment.