[telemetry] Fix telemetry vars template path (#4938)
The template is referenced relative to the script path and this could results in errors in case script is run from root. Add explicit path to the template file name. Also, moving telemetry_var template to template dir. And remove double quotes from around json dict. signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
This commit is contained in:
parent
b4452edb8a
commit
ceace4b605
@ -22,7 +22,8 @@ RUN apt-get clean -y && \
|
|||||||
apt-get autoremove -y && \
|
apt-get autoremove -y && \
|
||||||
rm -rf /debs
|
rm -rf /debs
|
||||||
|
|
||||||
COPY ["start.sh", "telemetry.sh", "dialout.sh", "telemetry_vars.j2", "/usr/bin/"]
|
COPY ["start.sh", "telemetry.sh", "dialout.sh", "/usr/bin/"]
|
||||||
|
COPY ["telemetry_vars.j2", "/usr/share/sonic/templates/"]
|
||||||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
|
||||||
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
|
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
|
||||||
COPY ["critical_processes", "/etc/supervisor"]
|
COPY ["critical_processes", "/etc/supervisor"]
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
EXIT_TELEMETRY_VARS_FILE_NOT_FOUND=1
|
||||||
|
TELEMETRY_VARS_FILE=/usr/share/sonic/templates/telemetry_vars.j2
|
||||||
|
|
||||||
|
if [ ! -f "$TELEMETRY_VARS_FILE" ]; then
|
||||||
|
echo "Telemetry vars template file not found"
|
||||||
|
exit $EXIT_TELEMETRY_VARS_FILE_NOT_FOUND
|
||||||
|
fi
|
||||||
|
|
||||||
# Try to read telemetry and certs config from ConfigDB.
|
# Try to read telemetry and certs config from ConfigDB.
|
||||||
# Use default value if no valid config exists
|
# Use default value if no valid config exists
|
||||||
TELEMETRY_VARS=$(sonic-cfggen -d -t telemetry_vars.j2)
|
TELEMETRY_VARS=$(sonic-cfggen -d -t $TELEMETRY_VARS_FILE)
|
||||||
TELEMETRY_VARS=${TELEMETRY_VARS//[\']/\"}
|
TELEMETRY_VARS=${TELEMETRY_VARS//[\']/\"}
|
||||||
X509=$(echo $TELEMETRY_VARS | jq -r '.x509')
|
X509=$(echo $TELEMETRY_VARS | jq -r '.x509')
|
||||||
GNMI=$(echo $TELEMETRY_VARS | jq -r '.gnmi')
|
GNMI=$(echo $TELEMETRY_VARS | jq -r '.gnmi')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"certs": "{% if "certs" in TELEMETRY.keys() %}{{ TELEMETRY["certs"] }}{% endif %}",
|
"certs": {% if "certs" in TELEMETRY.keys() %}{{ TELEMETRY["certs"] }}{% else %}""{% endif %},
|
||||||
"gnmi" : "{% if "gnmi" in TELEMETRY.keys() %}{{ TELEMETRY["gnmi"] }}{% endif %}",
|
"gnmi" : {% if "gnmi" in TELEMETRY.keys() %}{{ TELEMETRY["gnmi"] }}{% else %}""{% endif %},
|
||||||
"x509" : "{% if "x509" in DEVICE_METADATA.keys() %}{{ DEVICE_METADATA["x509"] }}{% endif %}"
|
"x509" : {% if "x509" in DEVICE_METADATA.keys() %}{{ DEVICE_METADATA["x509"] }}{% else %}""{% endif %}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user