Skip to content

Commit f41ecca

Browse files
authored
Implementation of a Monitoring Daemon for storage devices in SONiC switches (#433)
* Initial commit of ssdmond
1 parent 28302d4 commit f41ecca

File tree

16 files changed

+1026
-0
lines changed

16 files changed

+1026
-0
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ parameters:
5656
- name: sensormond
5757
root_dir: sonic-sensormond
5858
python3: true
59+
- name: stormond
60+
root_dir: sonic-stormond
61+
python3: true
5962
- name: artifactBranch
6063
type: string
6164
default: 'refs/heads/master'

sonic-stormond/pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -vv

sonic-stormond/scripts/stormond

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

sonic-stormond/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[aliases]
2+
test=pytest

sonic-stormond/setup.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name='sonic-stormond',
5+
version='1.0',
6+
description='Storage Device Monitoring Daemon for SONiC',
7+
license='Apache 2.0',
8+
author='SONiC Team',
9+
author_email='[email protected]',
10+
url='https://github.com/sonic-net/sonic-platform-daemons',
11+
maintainer='Ashwin Srinivasan',
12+
maintainer_email='[email protected]',
13+
scripts=[
14+
'scripts/stormond',
15+
],
16+
setup_requires=[
17+
'pytest-runner',
18+
'wheel'
19+
],
20+
install_requires=[
21+
'enum34',
22+
'sonic-py-common',
23+
],
24+
tests_require=[
25+
'mock>=2.0.0',
26+
'pytest',
27+
'pytest-cov',
28+
],
29+
classifiers=[
30+
'Development Status :: 4 - Beta',
31+
'Environment :: No Input/Output (Daemon)',
32+
'Intended Audience :: Developers',
33+
'Intended Audience :: Information Technology',
34+
'Intended Audience :: System Administrators',
35+
'License :: OSI Approved :: Apache Software License',
36+
'Natural Language :: English',
37+
'Operating System :: POSIX :: Linux',
38+
'Topic :: System :: Hardware',
39+
],
40+
keywords='sonic SONiC ssd Ssd SSD ssdmond storage stormond storagemond',
41+
test_suite='setup.get_test_suite'
42+
)

sonic-stormond/tests/__init__.py

Whitespace-only changes.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'''
2+
Mock implementation of swsscommon package for unit testing
3+
'''
4+
5+
from swsssdk import ConfigDBConnector, SonicDBConfig, SonicV2Connector
6+
7+
STATE_DB = ''
8+
9+
10+
class Table:
11+
def __init__(self, db, table_name):
12+
self.table_name = table_name
13+
self.mock_dict = {}
14+
self.mock_keys = ['sda']
15+
16+
def _del(self, key):
17+
del self.mock_dict[key]
18+
pass
19+
20+
def set(self, key, fvs):
21+
self.mock_dict[key] = fvs.fv_dict
22+
pass
23+
24+
def get(self, key):
25+
if key in self.mock_dict:
26+
return self.mock_dict[key]
27+
return None
28+
29+
def get_size(self):
30+
return (len(self.mock_dict))
31+
32+
def getKeys(self):
33+
return self.mock_keys
34+
35+
def hgetall(self):
36+
return self.mock_dict
37+
38+
39+
class FieldValuePairs:
40+
fv_dict = {}
41+
42+
def __init__(self, tuple_list):
43+
if isinstance(tuple_list, list) and isinstance(tuple_list[0], tuple):
44+
self.fv_dict = dict(tuple_list)
45+
46+
def __setitem__(self, key, kv_tuple):
47+
self.fv_dict[kv_tuple[0]] = kv_tuple[1]
48+
49+
def __getitem__(self, key):
50+
return self.fv_dict[key]
51+
52+
def __eq__(self, other):
53+
if not isinstance(other, FieldValuePairs):
54+
# don't attempt to compare against unrelated types
55+
return NotImplemented
56+
57+
return self.fv_dict == other.fv_dict
58+
59+
def __repr__(self):
60+
return repr(self.fv_dict)
61+
62+
def __str__(self):
63+
return repr(self.fv_dict)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""
2+
Mock implementation of sonic_platform package for unit testing
3+
"""
4+
5+
from . import pcie
6+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Mock implementation of sonic_platform package for unit testing
3+
"""
4+
5+
from sonic_platform_base.pcie_base import PcieBase
6+
7+
8+
class Pcie(PcieBase):
9+
def __init__(self):
10+
self.platform_pcieutil = "/tmp/Pcie"
11+
12+
def __str__(self):
13+
return self.platform_pcieutil
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)