Skip to content

Commit

Permalink
Adapt to config engine change to load platform info properly (sonic-n…
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms authored Feb 20, 2018
1 parent 63309c5 commit 35967e5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def load_minigraph():
client = config_db.redis_clients[config_db.CONFIG_DB]
client.flushdb()
if os.path.isfile('/etc/sonic/init_cfg.json'):
command = "{} -m -j /etc/sonic/init_cfg.json --write-to-db".format(SONIC_CFGGEN_PATH)
command = "{} -H -m -j /etc/sonic/init_cfg.json --write-to-db".format(SONIC_CFGGEN_PATH)
else:
command = "{} -m --write-to-db".format(SONIC_CFGGEN_PATH)
command = "{} -H -m --write-to-db".format(SONIC_CFGGEN_PATH)
run_command(command, display_cmd=True)
client.set(config_db.INIT_INDICATOR, 1)
if os.path.isfile('/etc/sonic/acl.json'):
Expand Down
6 changes: 3 additions & 3 deletions psuutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
PLATFORM_ROOT_PATH_DOCKER = '/usr/share/sonic/platform'
SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen'
MINIGRAPH_PATH = '/etc/sonic/minigraph.xml'
HWSKU_KEY = "DEVICE_METADATA['localhost']['hwsku']"
PLATFORM_KEY = 'platform'
HWSKU_KEY = 'DEVICE_METADATA.localhost.hwsku'
PLATFORM_KEY = 'DEVICE_METADATA.localhost.platform'

# Global platform-specific psuutil class instance
platform_psuutil = None
Expand Down Expand Up @@ -70,7 +70,7 @@ def log_error(msg, also_print_to_console=False):
# Returns platform and HW SKU
def get_platform_and_hwsku():
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-v', PLATFORM_KEY],
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
stderr=subprocess.STDOUT)
Expand Down
4 changes: 2 additions & 2 deletions scripts/decode-syseeprom
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ except ImportError, e:


SONIC_CFGGEN = '/usr/local/bin/sonic-cfggen'
PLATFORM_KEY = 'platform'
PLATFORM_KEY = 'DEVICE_METADATA.localhost.platform'

PLATFORM_ROOT = '/usr/share/sonic/device'

Expand All @@ -32,7 +32,7 @@ CACHE_FILE = 'syseeprom_cache'
# Returns platform and HW SKU
def get_platform():
try:
proc = subprocess.Popen([SONIC_CFGGEN, '-v', PLATFORM_KEY],
proc = subprocess.Popen([SONIC_CFGGEN, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
stderr=subprocess.STDOUT)
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ main() {

save_cmd "docker exec -it syncd saidump" "saidump"

local platform="$(/usr/local/bin/sonic-cfggen -v platform)"
local platform="$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)"
if [[ $platform == *"mlnx"* ]]; then
local sai_dump_filename="/tmp/sai_sdk_dump_$(date +"%m_%d_%Y_%I_%M_%p")"
docker exec -it syncd saisdkdump -f $sai_dump_filename
Expand Down
2 changes: 1 addition & 1 deletion scripts/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function stop_sonic_services()
}

# Obtain our platform as we will mount directories with these names in each docker
PLATFORM=`sonic-cfggen -v platform`
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.hwsku.platform`

DEVPATH="/usr/share/sonic/device"
REBOOT="platform_reboot"
Expand Down
4 changes: 2 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ def summary():
username = getpass.getuser()

PLATFORM_TEMPLATE_FILE = "/tmp/cli_platform_{0}.j2".format(username)
PLATFORM_TEMPLATE_CONTENTS = "Platform: {{ platform }}\n" \
"HwSKU: {{ DEVICE_METADATA['localhost']['hwsku'] }}\n" \
PLATFORM_TEMPLATE_CONTENTS = "Platform: {{ DEVICE_METADATA.localhost.platform }}\n" \
"HwSKU: {{ DEVICE_METADATA.localhost.hwsku }}\n" \
"ASIC: {{ asic_type }}"

# Create a temporary Jinja2 template file to use with sonic-cfggen
Expand Down

0 comments on commit 35967e5

Please sign in to comment.