Skip to content

assaabloy-ppi/salt-channel-python

Repository files navigation

salt-channel-python

Python 3 implementation of Salt Channel v2.

Both classic and asyncronous (asyncio based) APIs supported.

Quick start

After repo cloning to initialize virtualenv use:

make bootstrap

For list of current options available, use:

make

Status

Release v2.0

Current implementation is SaltChannel v2-draft8 compliant.

See: https://github.com/assaabloy-ppi/salt-channel/blob/master/files/spec/drafts/salt-channel-v2-draft8.md

Usage examples

See basic client-server session examples at dev/example_session???.py:

  • Source files WITHOUT _a suffix uses syncronous API.
  • Source files WITH _a suffix uses asyncronous API.

API notes:

  • Basic API is asyncronous (e.g. SaltClientSession.handshake() is coroutine, not a function).
  • Sync API calls are suffixed with _sync for each API coroutine.
  • Be carefull, do not mix sync & async naming (keep in mind: read() is coroutine, when read_sync() is corresponding syncronous equivalent function).
  • Internal details: sync API calls are autogenerated by wrapping each async call with loop.run_until_complete() (see Syncizer metaclass in util/__init__.py).

Package 'saltlib'

This package is abstraction layer above different NaCl-based crypto libraries with 'pythonized' API style.

For now next underlying crypto APIs are supported:

  • LIB_TYPE_NATIVE - ctypes based bindings to system 'libsodium' library.
  • LIB_TYPE_PYNACL - PyNaCl package.
  • LIB_TYPE_TWEETNACL_EXT - Native Python C extension calling original tweetnacl C code.

Current limitation: manual dependency installation required.

  • PyNaCl

python3 -m pip install --user PyNaCl

  • python-tweetnacl

python3 -m pip install --user git+https://github.com/ppmag/python-tweetnacl.git#egg=tweetnacl

Log entries

  • 2018-07-18, Alex: documentation improvement
  • 2017-11-10, Alex: Release v2.0, (v2-draft8 compliant)
  • 2017-07-05, Alex: SaltLib package (NaCl API layer) is ready
  • 2017-06-15, Frans: repo created on Github. MIT License.