Skip to content
8 changes: 8 additions & 0 deletions tests/generic_config_updater/gu_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
FILES_DIR = os.path.join(BASE_DIR, "files")
TEMPLATES_DIR = os.path.join(BASE_DIR, "templates")
TMP_DIR = '/tmp'
HOST_NAME = "localhost"
ASIC_PREFIX = "asic"


def generate_tmpfile(duthost):
Expand All @@ -40,6 +42,12 @@ def apply_patch(duthost, json_data, dest_file):
json_data: Source json patch to apply
dest_file: Destination file on duthost
"""
if duthost.is_multi_asic:
for operation in json_data:
if not operation["path"].startswith("/{}".format(HOST_NAME)) and \
not operation["path"].startswith("/{}".format(ASIC_PREFIX)):
operation["path"] = "/" + HOST_NAME + operation["path"]

duthost.copy(content=json.dumps(json_data, indent=4), dest=dest_file)

cmds = 'config apply-patch {}'.format(dest_file)
Expand Down