-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mellanox] optimize new platform api #3289
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2e5e6b2
[sonic_platform.sfp]
c63b46e
[sonic_platform.chassis] initialize watchdog only when referenced.
f826ac7
[sonic_platform.chassis] optimize chassis's initialization by
d8c2105
[sonic_platform.chassis] update self.eeprom to self._eeprom in order …
71e6751
[sonic_platform.chassis] add initialization for sfp_event
9f081c5
[sonic_platform] optimize initialization.
5f7cbec
[sonic_platform.chassis]improve reboot-cause support
3f48f05
[sonic_platform.platform] improve the logic of determining whether it…
3fdff1f
[sonic_platform]only initialize sfp modules when related apis are called
e8177b5
[sonic_platform]chassis: refractor reboot cause handling. using a dic…
39b79c2
[sonic_platform] sfp: optimizing eeprom data read by combining multip…
2d48e54
[sonic_platform]introduce an explicit flag indicating whether sfp has…
38aa635
[chassis]
5e22018
Merge pull request #6 from stephenxs/npapi-based-daemon-optimize
stephenxs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__all__ = ["platform", "chassis"] | ||
from sonic_platform import * | ||
This file contains 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
45 changes: 45 additions & 0 deletions
45
platform/mellanox/mlnx-platform-api/sonic_platform/platform.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
############################################################################# | ||
# Mellanox | ||
# | ||
# implementation of new platform api | ||
############################################################################# | ||
|
||
try: | ||
import subprocess | ||
from sonic_platform_base.platform_base import PlatformBase | ||
from sonic_platform.chassis import Chassis | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
class Platform(PlatformBase): | ||
def __init__(self): | ||
PlatformBase.__init__(self) | ||
if self._is_host(): | ||
self._chassis = Chassis() | ||
else: | ||
self._chassis = Chassis() | ||
self._chassis.initialize_psu() | ||
self._chassis.initialize_fan() | ||
self._chassis.initialize_eeprom() | ||
self._chassis.initialize_components_list() | ||
|
||
def _is_host(self): | ||
""" | ||
Test whether current process is running on the host or an docker | ||
return True for host and False for docker | ||
""" | ||
is_host = False | ||
try: | ||
proc = subprocess.Popen("docker --version 2>/dev/null", stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) | ||
stdout = proc.communicate()[0] | ||
proc.wait() | ||
result = stdout.rstrip('\n') | ||
if result != '': | ||
is_host = True | ||
|
||
except OSError, e: | ||
pass | ||
|
||
return is_host |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't import wildcard in production code.