Skip to content
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

Rename module from 'sswsdk' to 'swsssdk' #4

Merged
merged 1 commit into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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', ...]
```
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/sswsdk/dbconnector.py → src/swsssdk/dbconnector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Database connection module for SSW.
Database connection module for SwSS
"""
from . import _connector_map, logger
from .interface import DBInterface
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/sswsdk/exceptions.py → src/swsssdk/exceptions.py
Original file line number Diff line number Diff line change
@@ -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)
"""
Expand Down Expand Up @@ -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. """
2 changes: 1 addition & 1 deletion src/sswsdk/interface.py → src/swsssdk/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions test/test_moduleLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the v1 support? i don't think we still need it and even if it is kept here, it is no longer compatible with v1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lguohan: I'm unfamiliar with this. Can you confirm? If so, I'll remove v1 support in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could merge this first and clean the legacy stuffs in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I created an issue for it: #5

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