-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf910df
commit 08d5ecd
Showing
16 changed files
with
856 additions
and
0 deletions.
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 @@ | ||
[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 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 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"', | ||
'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', | ||
'Topic :: System :: Hardware', | ||
], | ||
keywords='sonic SONiC ssd Ssd SSD ssdmond storage stormond storagemond', | ||
test_suite='setup.get_test_suite' | ||
) |
Empty file.
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,15 @@ | ||
|
||
""" | ||
Mock implementation of sonic_platform package for unit testing | ||
""" | ||
|
||
# TODO: Clean this up once we no longer need to support Python 2 | ||
import sys | ||
if sys.version_info.major == 3: | ||
from unittest import mock | ||
else: | ||
import mock | ||
|
||
class MockStorageDevice(): | ||
def __init__(self): | ||
super(MockStorageDevice, self).__init__() |
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,6 @@ | ||
""" | ||
Mock implementation of sonic_platform package for unit testing | ||
""" | ||
|
||
from . import ssd | ||
|
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,13 @@ | ||
""" | ||
Mock implementation of sonic_platform package for unit testing | ||
""" | ||
|
||
from sonic_platform_base.storage_base import StorageBase | ||
|
||
|
||
class Storage(StorageBase): | ||
def __init__(self): | ||
self.platform_Storageutil = "/tmp/Storage" | ||
|
||
def __str__(self): | ||
return self.platform_Storageutil |
1 change: 1 addition & 0 deletions
1
sonic-stormond/tests/mocked_libs/sonic_platform_base/__init__.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 @@ | ||
|
Empty file.
127 changes: 127 additions & 0 deletions
127
sonic-stormond/tests/mocked_libs/sonic_platform_base/sonic_storage/ssd.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,127 @@ | ||
# | ||
# ssd.py | ||
# | ||
# Generic implementation of the SSD health API | ||
# SSD models supported: | ||
# - InnoDisk | ||
# - StorFly | ||
# - Virtium | ||
|
||
try: | ||
import re | ||
import subprocess | ||
from .storage_base import StorageBase | ||
except ImportError as e: | ||
raise ImportError (str(e) + "- required module not found") | ||
|
||
SMARTCTL = "smartctl {} -a" | ||
INNODISK = "iSmart -d {}" | ||
VIRTIUM = "SmartCmd -m {}" | ||
|
||
NOT_AVAILABLE = "N/A" | ||
|
||
# Set Vendor Specific IDs | ||
INNODISK_HEALTH_ID = 169 | ||
INNODISK_TEMPERATURE_ID = 194 | ||
SWISSBIT_HEALTH_ID = 248 | ||
SWISSBIT_TEMPERATURE_ID = 194 | ||
|
||
class SsdUtil(StorageBase): | ||
""" | ||
Generic implementation of the SSD health API | ||
""" | ||
|
||
def __init__(self, diskdev): | ||
model = 'InnoDisk Corp. - mSATA 3IE3' | ||
serial = 'BCA11712190600251' | ||
firmware = 'S16425cG' | ||
temperature = 32.3 | ||
health = 91.6 | ||
ssd_info = NOT_AVAILABLE | ||
vendor_ssd_info = NOT_AVAILABLE | ||
io_reads = 20000 | ||
io_writes = 20005 | ||
reserved_blocks = 3746218 | ||
|
||
def get_health(self): | ||
""" | ||
Retrieves current disk health in percentages | ||
Returns: | ||
A float number of current ssd health | ||
e.g. 83.5 | ||
""" | ||
return self.health | ||
|
||
def get_temperature(self): | ||
""" | ||
Retrieves current disk temperature in Celsius | ||
Returns: | ||
A float number of current temperature in Celsius | ||
e.g. 40.1 | ||
""" | ||
return self.temperature | ||
|
||
def get_model(self): | ||
""" | ||
Retrieves model for the given disk device | ||
Returns: | ||
A string holding disk model as provided by the manufacturer | ||
""" | ||
return self.model | ||
|
||
def get_firmware(self): | ||
""" | ||
Retrieves firmware version for the given disk device | ||
Returns: | ||
A string holding disk firmware version as provided by the manufacturer | ||
""" | ||
return self.firmware | ||
|
||
def get_serial(self): | ||
""" | ||
Retrieves serial number for the given disk device | ||
Returns: | ||
A string holding disk serial number as provided by the manufacturer | ||
""" | ||
return self.serial | ||
|
||
def get_vendor_output(self): | ||
""" | ||
Retrieves vendor specific data for the given disk device | ||
Returns: | ||
A string holding some vendor specific disk information | ||
""" | ||
return self.vendor_ssd_info | ||
|
||
def get_io_writes(self): | ||
""" | ||
Retrieves the total number of Input/Output (I/O) writes done on an SSD | ||
Returns: | ||
An integer value of the total number of I/O writes | ||
""" | ||
return self.io_writes | ||
|
||
def get_io_reads(self): | ||
""" | ||
Retrieves the total number of Input/Output (I/O) writes done on an SSD | ||
Returns: | ||
An integer value of the total number of I/O writes | ||
""" | ||
return self.io_reads | ||
|
||
def get_reserves_blocks(self): | ||
""" | ||
Retrieves the total number of reserved blocks in an SSD | ||
Returns: | ||
An integer value of the total number of reserved blocks | ||
""" | ||
return self.reserved_blocks |
122 changes: 122 additions & 0 deletions
122
sonic-stormond/tests/mocked_libs/sonic_platform_base/sonic_storage/storage_base.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,122 @@ | ||
# | ||
# storage_base.py | ||
# | ||
# Abstract base class for implementing platform-specific | ||
# Storage information gathering functionality for SONiC | ||
# | ||
|
||
try: | ||
import abc | ||
except ImportError as e: | ||
raise ImportError(str(e) + " - required module not found") | ||
|
||
# | ||
# storage_base.py | ||
# | ||
# Base class for implementing common Storage Device 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 | ||
|
||
@abc.abstractmethod | ||
def get_health(self): | ||
""" | ||
Retrieves current disk health in percentages | ||
Returns: | ||
A float number of current ssd health | ||
e.g. 83.5 | ||
""" | ||
return 91.6 | ||
|
||
@abc.abstractmethod | ||
def get_temperature(self): | ||
""" | ||
Retrieves current disk temperature in Celsius | ||
Returns: | ||
A float number of current temperature in Celsius | ||
e.g. 40.1 | ||
""" | ||
return 32.3 | ||
|
||
@abc.abstractmethod | ||
def get_model(self): | ||
""" | ||
Retrieves model for the given disk device | ||
Returns: | ||
A string holding disk model as provided by the manufacturer | ||
""" | ||
return '' | ||
|
||
@abc.abstractmethod | ||
def get_firmware(self): | ||
""" | ||
Retrieves firmware version for the given disk device | ||
Returns: | ||
A string holding disk firmware version as provided by the manufacturer | ||
""" | ||
return '' | ||
|
||
@abc.abstractmethod | ||
def get_serial(self): | ||
""" | ||
Retrieves serial number for the given disk device | ||
Returns: | ||
A string holding disk serial number as provided by the manufacturer | ||
""" | ||
return '' | ||
|
||
@abc.abstractmethod | ||
def get_vendor_output(self): | ||
""" | ||
Retrieves vendor specific data for the given disk device | ||
Returns: | ||
A string holding some vendor specific disk information | ||
""" | ||
return '' | ||
|
||
def get_io_reads(self): | ||
""" | ||
Retrieves the total number of Input/Output (I/O) reads done on an SSD | ||
Returns: | ||
An integer value of the total number of I/O reads | ||
""" | ||
return 20000 | ||
|
||
@abc.abstractmethod | ||
def get_io_writes(self): | ||
""" | ||
Retrieves the total number of Input/Output (I/O) writes done on an SSD | ||
Returns: | ||
An integer value of the total number of I/O writes | ||
""" | ||
return 20005 | ||
|
||
@abc.abstractmethod | ||
def get_reserves_blocks(self): | ||
""" | ||
Retrieves the total number of reserved blocks in an SSD | ||
Returns: | ||
An integer value of the total number of reserved blocks | ||
""" | ||
return 3746218 |
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,5 @@ | ||
''' | ||
Mock implementation of swsscommon package for unit testing | ||
''' | ||
|
||
from . import swsscommon |
Oops, something went wrong.