[docker]: get hostname from config db instead of minigraph (#3004)

minigraph may not be always available on the some system configuration.
Should use config db as the source of truth.
This commit is contained in:
lguohan 2019-06-13 22:24:09 -07:00 committed by GitHub
parent 383fc0fa4b
commit 8f6ae90cba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,8 +130,8 @@ start() {
{%- else %} {%- else %}
# Obtain our HWSKU as we will mount directories with these names in each docker # Obtain our HWSKU as we will mount directories with these names in each docker
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'` HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'`
HOSTNAME=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hostname"]'`
{%- endif %} {%- endif %}
HOSTNAME=`sonic-cfggen -m -v 'DEVICE_METADATA["localhost"]["hostname"]'`
if [ -z "$HOSTNAME" ] || ! [[ $HOSTNAME =~ ^[a-zA-Z0-9.\-]*$ ]]; then if [ -z "$HOSTNAME" ] || ! [[ $HOSTNAME =~ ^[a-zA-Z0-9.\-]*$ ]]; then
HOSTNAME=`hostname` HOSTNAME=`hostname`
fi fi