[Smartswitch] Host container differentiation for sensor commands#604
Merged
judyjoseph merged 4 commits intosonic-net:masterfrom Nov 3, 2025
Merged
[Smartswitch] Host container differentiation for sensor commands#604judyjoseph merged 4 commits intosonic-net:masterfrom
judyjoseph merged 4 commits intosonic-net:masterfrom
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
@vvolam and @rameshraghupathy please review |
oleksandrivantsiv
approved these changes
Oct 17, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds host/container differentiation for sensor commands in ModuleBase class for smartswitch functionality. The changes enable sensord commands to be executed properly both when called from within the pmon docker container and when called from the host system during different operations.
- Introduces host detection mechanism using the presence of
/.dockerenvfile - Modifies sensor handling methods to use subprocess calls with docker exec when running on host
- Updates command execution to differentiate between host and container environments
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sonic_platform_base/module_base.py | Adds _is_host() method and modifies sensor removal/addition methods to use subprocess calls with docker exec prefixes when running on host |
| tests/module_base_test.py | Updates test cases to cover both host and container execution scenarios with proper mocking of subprocess calls |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
vvolam
approved these changes
Oct 17, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
judyjoseph
approved these changes
Nov 3, 2025
Collaborator
|
Cherry-pick PR to msft-202506: Azure/sonic-platform-common.msft#111 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Differentiate commands being executed in host and container seperately for some smartswitch specific functions,
sensord commands can only be executed inside hte pmon docker container, so these commands need to differentiate between host and container execution
Motivation and Context
This is done because these functions are called from inside the pmon docker during chassis command execution and from the host directly during reboot command execution
How Has This Been Tested?
Manual test with:
reboot -d DPU0and
config chassis modules startup DPU0Additional Information (Optional)