sonic-buildimage/platform
Joe LeVeque 172354d36a
[sonic-py-common] get_platform(): Refactor method of retrieving platform identifier (#5094)
Applications running in the host OS can read the platform identifier from /host/machine.conf. When loading configuration, sonic-config-engine *needs* to read the platform identifier from machine.conf, as it it responsible for populating the value in Config DB.

When an application is running inside a Docker container, the machine.conf file is not accessible, as the /host directory is not mounted. So we need to retrieve the platform identifier from Config DB if get_platform() is called from inside a Docker 
container. However, we can't simply check that we're running in a Docker container because the host OS of the SONiC virtual switch is running inside a Docker container. So I refactored `get_platform()` to:
    1. Read from the `PLATFORM` environment variable if it exists (which is defined in a virtual switch Docker container)
    2. Read from machine.conf if possible (works in the host OS of a standard SONiC image, critical for sonic-config-engine at boot)
    3. Read the value from Config DB (needed for Docker containers running in SONiC, as machine.conf is not accessible to them)

- Also fix typo in daemon_base.py
- Also changes to align `get_hwsku()` with `get_platform()`
2020-08-04 23:51:35 -07:00
..
barefoot [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
broadcom [Python] Migrate applications/scripts to import sonic-py-common package (#5043) 2020-08-03 11:43:12 -07:00
cavium [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
centec [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
generic [dockers] Rename 'docker-snmp-sv2' to 'docker-snmp' (#4699) 2020-06-11 16:04:23 -07:00
innovium [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
marvell [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
marvell-arm64 [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
marvell-armhf [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
mellanox [Python] Migrate applications/scripts to import sonic-py-common package (#5043) 2020-08-03 11:43:12 -07:00
nephos [build]: wait for conflicts package to be uninstalled (#5039) 2020-07-27 10:46:20 -07:00
p4 [docker-orchagent]: make build depends only on sairedis package (#4880) 2020-07-12 18:08:51 +00:00
template [docker-syncd-vs]: Convert syncd-vs docker to buster (#4726) 2020-06-09 09:07:25 -07:00
vs [sonic-py-common] get_platform(): Refactor method of retrieving platform identifier (#5094) 2020-08-04 23:51:35 -07:00