-
Notifications
You must be signed in to change notification settings - Fork 209
Implementation of a Monitoring Daemon for storage devices in SONiC switches #433
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
Merged
Merged
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
dd83c8f
Initial commit of ssdmond
276f08e
Added support for dynamic fields. Unified table update function. Adde…
d2f3d49
Added eMMC checks. Added checks before accessing ssdutil objs. Added …
4582ffc
Removed references to 'ssd' and its variants and replaced with 'stora…
d8e3930
Created StorageDevices class for device ratification and object creation
8ad06d9
Renamed daemon to 'storagemond', changed unit tests to reflect the same
b95d4e2
Renamed storagemond directory and corresponding change to setup.py
2a0b6b0
Added support for FS IO RW. Cleaned up bugs. Renamed ssd_base --> sto…
bf910df
Renamed test dirs, changed import to match platform-common dirname ch…
08d5ecd
Made core algorithm changes per HLD
f647149
Renamed dir per sonic naming convention
a555cd4
Removed a rogue debugging statuement
898f876
Made changes per review comments
6ba0155
Added UTs, increased coverage
f62f271
Changed log_info to log_error
7118c91
Changed function name to match corr. change in SsdUtil
d246ac5
Moved get_dynamic_field() to before timeout
335b2c8
Cleaned up signal handling, added more UTs
b2ec903
Added another UT
b146d72
Fixed a bug that was causing sync-to-disk to fail
9a94c07
Fixed an eror with _load_fsio_rw_statedb that would assign None value…
959c946
Lowered severity for expected log when storage object isnt instantiated
d89a8bd
Fixed potential bug where if dynamic_fields fails before populating s…
ccbe350
Fixed indentation error
4e2f48d
Removed untracked ycabled files that were committed by mistake
7c5c88f
Swapped logger for syslogger per prgeor review
7b84cc1
log_error --> log_info per review comment
b31f591
Made changes per prgeor review comments
c83d024
Made changes per prgeor walkthrough review
ea45fae
Test mods corresponding to daemon nunction name mods
c36f40d
More Uts to pass coverage
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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [pytest] | ||
| addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -vv |
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [aliases] | ||
| test=pytest |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from setuptools import setup | ||
|
|
||
| setup( | ||
| name='sonic-stormond', | ||
| version='1.0', | ||
| description='Storage Device Monitoring Daemon for SONiC', | ||
| license='Apache 2.0', | ||
| author='SONiC Team', | ||
| author_email='[email protected]', | ||
| url='https://github.com/sonic-net/sonic-platform-daemons', | ||
| maintainer='Ashwin Srinivasan', | ||
| maintainer_email='[email protected]', | ||
| scripts=[ | ||
| 'scripts/stormond', | ||
| ], | ||
| setup_requires=[ | ||
| 'pytest-runner', | ||
| 'wheel' | ||
| ], | ||
| install_requires=[ | ||
| 'enum34; python_version < "3.4"', | ||
| 'sonic-py-common', | ||
| ], | ||
| tests_require=[ | ||
| 'mock>=2.0.0; python_version < "3.3"', | ||
ashwnsri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'pytest', | ||
| 'pytest-cov', | ||
| ], | ||
| classifiers=[ | ||
| 'Development Status :: 4 - Beta', | ||
| 'Environment :: No Input/Output (Daemon)', | ||
| 'Intended Audience :: Developers', | ||
| 'Intended Audience :: Information Technology', | ||
| 'Intended Audience :: System Administrators', | ||
| 'License :: OSI Approved :: Apache Software License', | ||
| 'Natural Language :: English', | ||
| 'Operating System :: POSIX :: Linux', | ||
| 'Programming Language :: Python :: 2.7', | ||
ashwnsri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'Topic :: System :: Hardware', | ||
| ], | ||
| keywords='sonic SONiC ssd Ssd SSD ssdmond storage stormond storagemond', | ||
| test_suite='setup.get_test_suite' | ||
| ) | ||
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| ''' | ||
| Mock implementation of swsscommon package for unit testing | ||
| ''' | ||
|
|
||
| from swsssdk import ConfigDBConnector, SonicDBConfig, SonicV2Connector | ||
|
|
||
| STATE_DB = '' | ||
|
|
||
|
|
||
| class Table: | ||
| def __init__(self, db, table_name): | ||
| self.table_name = table_name | ||
| self.mock_dict = {} | ||
| self.mock_keys = ['sda'] | ||
|
|
||
| def _del(self, key): | ||
| del self.mock_dict[key] | ||
| pass | ||
|
|
||
| def set(self, key, fvs): | ||
| self.mock_dict[key] = fvs.fv_dict | ||
| pass | ||
|
|
||
| def get(self, key): | ||
| if key in self.mock_dict: | ||
| return self.mock_dict[key] | ||
| return None | ||
|
|
||
| def get_size(self): | ||
| return (len(self.mock_dict)) | ||
|
|
||
| def getKeys(self): | ||
| return self.mock_keys | ||
|
|
||
| def hgetall(self): | ||
| return self.mock_dict | ||
|
|
||
|
|
||
| class FieldValuePairs: | ||
| fv_dict = {} | ||
|
|
||
| def __init__(self, tuple_list): | ||
| if isinstance(tuple_list, list) and isinstance(tuple_list[0], tuple): | ||
| self.fv_dict = dict(tuple_list) | ||
|
|
||
| def __setitem__(self, key, kv_tuple): | ||
| self.fv_dict[kv_tuple[0]] = kv_tuple[1] | ||
|
|
||
| def __getitem__(self, key): | ||
| return self.fv_dict[key] | ||
|
|
||
| def __eq__(self, other): | ||
| if not isinstance(other, FieldValuePairs): | ||
| # don't attempt to compare against unrelated types | ||
| return NotImplemented | ||
|
|
||
| return self.fv_dict == other.fv_dict | ||
|
|
||
| def __repr__(self): | ||
| return repr(self.fv_dict) | ||
|
|
||
| def __str__(self): | ||
| return repr(self.fv_dict) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| """ | ||
| Mock implementation of sonic_platform package for unit testing | ||
| """ | ||
|
|
||
| from . import pcie | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """ | ||
| Mock implementation of sonic_platform package for unit testing | ||
| """ | ||
|
|
||
| from sonic_platform_base.pcie_base import PcieBase | ||
|
|
||
|
|
||
| class Pcie(PcieBase): | ||
| def __init__(self): | ||
| self.platform_pcieutil = "/tmp/Pcie" | ||
|
|
||
| def __str__(self): | ||
| return self.platform_pcieutil |
1 change: 1 addition & 0 deletions
1
sonic-stormond/tests/mocked_libs/sonic_platform_base/__init__.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
Empty file.
102 changes: 102 additions & 0 deletions
102
sonic-stormond/tests/mocked_libs/sonic_platform_base/sonic_storage/storage_base.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # | ||
| # storage_base.py | ||
| # | ||
| # Base class for implementing common SSD health features | ||
| # | ||
|
|
||
|
|
||
| class StorageBase(object): | ||
| """ | ||
| Base class for interfacing with a SSD | ||
| """ | ||
| def __init__(self, diskdev): | ||
| """ | ||
| Constructor | ||
|
|
||
| Args: | ||
| diskdev: Linux device name to get parameters for | ||
| """ | ||
| pass | ||
|
|
||
| def get_health(self): | ||
| """ | ||
| Retrieves current disk health in percentages | ||
|
|
||
| Returns: | ||
| A float number of current ssd health | ||
| e.g. 83.5 | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_temperature(self): | ||
| """ | ||
| Retrieves current disk temperature in Celsius | ||
|
|
||
| Returns: | ||
| A float number of current temperature in Celsius | ||
| e.g. 40.1 | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_model(self): | ||
| """ | ||
| Retrieves model for the given disk device | ||
|
|
||
| Returns: | ||
| A string holding disk model as provided by the manufacturer | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_firmware(self): | ||
| """ | ||
| Retrieves firmware version for the given disk device | ||
|
|
||
| Returns: | ||
| A string holding disk firmware version as provided by the manufacturer | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_serial(self): | ||
| """ | ||
| Retrieves serial number for the given disk device | ||
|
|
||
| Returns: | ||
| A string holding disk serial number as provided by the manufacturer | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_vendor_output(self): | ||
| """ | ||
| Retrieves vendor specific data for the given disk device | ||
|
|
||
| Returns: | ||
| A string holding some vendor specific disk information | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_disk_io_reads(self): | ||
| """ | ||
| Retrieves the total number of Input/Output (I/O) reads done on a storage disk | ||
|
|
||
| Returns: | ||
| An integer value of the total number of I/O reads | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_disk_io_writes(self): | ||
| """ | ||
| Retrieves the total number of Input/Output (I/O) writes done on a storage disk | ||
|
|
||
| Returns: | ||
| An integer value of the total number of I/O writes | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| def get_reserved_blocks(self): | ||
| """ | ||
| Retrieves the total number of reserved blocks in an storage disk | ||
|
|
||
| Returns: | ||
| An integer value of the total number of reserved blocks | ||
| """ | ||
| raise NotImplementedError |
12 changes: 12 additions & 0 deletions
12
sonic-stormond/tests/mocked_libs/sonic_platform_base/sonic_storage/storage_devices.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
|
|
||
| BLKDEV_BASE_PATH = '' | ||
|
|
||
| class StorageDevices: | ||
| def __init__(self): | ||
| self.devices = {'sda' : None} | ||
|
|
||
| def _get_storage_devices(self): | ||
| pass | ||
|
|
||
| def _storage_device_object_factory(self, key): | ||
| pass |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ''' | ||
| Mock implementation of swsscommon package for unit testing | ||
| ''' | ||
|
|
||
| from . import swsscommon |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| ''' | ||
| Mock implementation of swsscommon package for unit testing | ||
| ''' | ||
|
|
||
| STATE_DB = '' | ||
|
|
||
|
|
||
| class Table: | ||
| def __init__(self, db, table_name): | ||
| self.table_name = table_name | ||
| self.mock_dict = {} | ||
|
|
||
| def _del(self, key): | ||
| del self.mock_dict[key] | ||
| pass | ||
|
|
||
| def set(self, key, fvs): | ||
| self.mock_dict[key] = fvs.fv_dict | ||
| pass | ||
|
|
||
| def get(self, key): | ||
| if key in self.mock_dict: | ||
| return self.mock_dict[key] | ||
| return None | ||
|
|
||
| def get_size(self): | ||
| return (len(self.mock_dict)) | ||
|
|
||
| def getKeys(self): | ||
| return list(self.mock_dict.keys()) | ||
|
|
||
|
|
||
| class FieldValuePairs: | ||
| fv_dict = {} | ||
|
|
||
| def __init__(self, tuple_list): | ||
| if isinstance(tuple_list, list) and isinstance(tuple_list[0], tuple): | ||
| self.fv_dict = dict(tuple_list) | ||
|
|
||
| def __setitem__(self, key, kv_tuple): | ||
| self.fv_dict[kv_tuple[0]] = kv_tuple[1] | ||
|
|
||
| def __getitem__(self, key): | ||
| return self.fv_dict[key] | ||
|
|
||
| def __eq__(self, other): | ||
| if not isinstance(other, FieldValuePairs): | ||
| # don't attempt to compare against unrelated types | ||
| return NotImplemented | ||
|
|
||
| return self.fv_dict == other.fv_dict | ||
|
|
||
| def __repr__(self): | ||
| return repr(self.fv_dict) | ||
|
|
||
| def __str__(self): | ||
| return repr(self.fv_dict) | ||
|
|
||
| class ConfigDBConnector: | ||
| pass | ||
|
|
||
| class SonicDBConfig: | ||
| pass | ||
|
|
||
| class SonicV2Connector: | ||
| pass |
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.
Uh oh!
There was an error while loading. Please reload this page.