diff --git a/README.md b/README.md index 69c44c961..d1b779639 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# Python-SSWSDK -Python utility library for sonic/switch state service database access. +# Python SwSS SDK +Python utility library for SONiC Switch State Service database access -See the [SONiC Website](http://azure.github.io/SONiC/) for more information about the SONiC project. +See the [SONiC Website](http://azure.github.io/SONiC/) for more information about the SONiC project Database names are defined by Switch State Service. See the [sonic-swss-common](https://github.com/Azure/sonic-swss-common/blob/master/common/schema.h) project. ### Example Usage ```python ->>> import sswsdk ->>> ssw = sswsdk.SonicV2Connector() ->>> ssw.db_list +>>> import swsssdk +>>> swss = swsssdk.SonicV2Connector() +>>> swss.db_list dict_keys(['COUNTERS_DB', 'ASIC_DB', 'APPL_DB']) ->>> dir(ssw) +>>> dir(swss) ['APPL_DB', 'ASIC_DB', 'CONNECT_RETRY_WAIT_TIME', 'COUNTERS_DB', 'DATA_RETRIEVAL_WAIT_TIME', 'KEYSPACE_EVENTS', 'KEYSPACE_PATTERN', 'PUB_SUB_MAXIMUM_DATA_WAIT', 'PUB_SUB_NOTIFICATION_TIMEOUT', 'REDIS_HOST', 'REDIS_PORT', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_connection_error_handler', '_onetime_connect', '_persistent_connect', '_subscribe_keyspace_notification', '_unavailable_data_handler', 'close', 'connect', 'db_list', 'db_map', 'get', 'get_all', 'get_dbid', 'get_redis_client', 'keys', 'keyspace_notification_channels', 'redis_clients', 'set'] ->>> ssw.connect(ssw.APPL_DB) ->>> ssw.keys(ssw.APPL_DB) +>>> swss.connect(swss.APPL_DB) +>>> swss.keys(swss.APPL_DB) [b'PORT_TABLE:Ethernet8', b'INTF_TABLE:Ethernet16:10.0.0.8/31', b'LLDP_ENTRY_TABLE:Ethernet4', b'PORT_TABLE:Ethernet76', b'PORT_TABLE_VALUE_QUEUE', b'NEIGH_TABLE:eth0:10.3.147.40', ...] ``` diff --git a/setup.py b/setup.py index 4dfa0ce48..2743e73a7 100644 --- a/setup.py +++ b/setup.py @@ -9,11 +9,11 @@ ] setup( - name='sswsdk', + name='swsssdk', version='2.0.1', - package_dir={'sswsdk': 'src/sswsdk'}, - packages=['sswsdk'], - package_data={'sswsdk': ['config/*.json']}, + package_dir={'swsssdk': 'src/swsssdk'}, + packages=['swsssdk'], + package_data={'swsssdk': ['config/*.json']}, license='Apache 2.0', author='SONiC Team', author_email='linuxnetdev@microsoft.com', diff --git a/src/sswsdk/__init__.py b/src/swsssdk/__init__.py similarity index 100% rename from src/sswsdk/__init__.py rename to src/swsssdk/__init__.py diff --git a/src/sswsdk/config/database.json b/src/swsssdk/config/database.json similarity index 100% rename from src/sswsdk/config/database.json rename to src/swsssdk/config/database.json diff --git a/src/sswsdk/dbconnector.py b/src/swsssdk/dbconnector.py similarity index 87% rename from src/sswsdk/dbconnector.py rename to src/swsssdk/dbconnector.py index a1bac2bb3..9fb8e8852 100644 --- a/src/sswsdk/dbconnector.py +++ b/src/swsssdk/dbconnector.py @@ -1,5 +1,5 @@ """ -Database connection module for SSW. +Database connection module for SwSS """ from . import _connector_map, logger from .interface import DBInterface @@ -35,5 +35,5 @@ def __init__(self, **kwargs): class DBConnector(SonicV1Connector): - logger.warning("DBConnector is DEPRECATED. 'sswsdk.dbconnector.DBConnector' -> 'sswsdk.SonicV1Connector'") + logger.warning("DBConnector is DEPRECATED. 'swsssdk.dbconnector.DBConnector' -> 'swsssdk.SonicV1Connector'") pass diff --git a/src/sswsdk/exceptions.py b/src/swsssdk/exceptions.py similarity index 91% rename from src/sswsdk/exceptions.py rename to src/swsssdk/exceptions.py index 982ab5053..9c4c9622f 100644 --- a/src/sswsdk/exceptions.py +++ b/src/swsssdk/exceptions.py @@ -1,8 +1,8 @@ -class SSWQueryError(Exception): +class SwSSQueryError(Exception): """ Base exception class """ -class UnavailableDataError(SSWQueryError): +class UnavailableDataError(SwSSQueryError): def __init__(self, message, data, *args, **kwargs): super(UnavailableDataError, self).__init__(message, *args, **kwargs) """ @@ -42,5 +42,5 @@ def __init__(self, message, data, *args, **kwargs): self.data = data if type(data) is bytes else data.encode('ascii') -class MissingClientError(SSWQueryError): +class MissingClientError(SwSSQueryError): """ Raised when a queried client wasn't found. """ diff --git a/src/sswsdk/interface.py b/src/swsssdk/interface.py similarity index 99% rename from src/sswsdk/interface.py rename to src/swsssdk/interface.py index ab66df6a3..eebc3bbc2 100644 --- a/src/sswsdk/interface.py +++ b/src/swsssdk/interface.py @@ -299,7 +299,7 @@ def _unavailable_data_handler(self, db_name, data): When the queried config is not available in Redis--wait until it is available. Two timeouts are at work here: 1. Notification timeout - how long to wait before giving up on receiving any given pub-sub message. - 2. Max data wait - sswsdk-specific. how long to wait for the data to populate (in absolute time) + 2. Max data wait - swsssdk-specific. how long to wait for the data to populate (in absolute time) """ start = time.time() logger.debug("Listening on pubsub channel '{}'".format(db_name)) diff --git a/src/sswsdk/util.py b/src/swsssdk/util.py similarity index 100% rename from src/sswsdk/util.py rename to src/swsssdk/util.py diff --git a/test/test_moduleLoad.py b/test/test_moduleLoad.py index ddf8fd4db..b769dbf4f 100644 --- a/test/test_moduleLoad.py +++ b/test/test_moduleLoad.py @@ -10,12 +10,12 @@ class Test_load_connector_map(TestCase): def test__load_connector_map(self): # noinspection PyUnresolvedReferences - import sswsdk + import swsssdk def test__db_map_attributes(self): - import sswsdk - db1 = sswsdk.SonicV1Connector() + import swsssdk + db1 = swsssdk.SonicV1Connector() self.assertTrue(all(hasattr(db1, db_name) for db_name in db1.db_map)) - db2 = sswsdk.SonicV2Connector() + db2 = swsssdk.SonicV2Connector() self.assertTrue(all(hasattr(db2, db_name) for db_name in db2.db_map)) pass