Skip to main content

open-source implementation of CORECONF (CoAP Management Interface)

Project description

pycoreconf

Open-source implementation library of CORECONF (CoAP Management Interface) for Python.

What is CORECONF?

The CoAP Management Interface (CORECONF) is a network management protocol designed for constrained devices and networks. It uses the CoAP protocol to maintain a low message footprint, follows a stateless client-server architecture, and manages resources and properties defined in a YANG data model.

CORECONF uses a CBOR mapping of YANG to keep message sizes extremely low, and substitutes the nodes' names for YANG Schema Item iDentifiers (SIDs). These are numeric values that are assigned to the model in ranges, so that each node has a corresponding SID. Moreover, the SIDs are assigned in a delta structure, which contributes to achieving a very small memory footprint.

Installation

From PyPI:

pip install pycoreconf

From source:

git clone https://github.com/alex-fddz/pycoreconf.git
cd pycoreconf
python3 setup.py install    # this might require root access

To uninstall

pip uninstall pycoreconf

Requirements & Setup

  • ltn22/pyang module. Allows the generation of the model's SID file including leaves' data types. Provides YANG IETF modules necessary for config validation.
  • SID file generated as follows (see tools/gen_sid.sh):
pyang --sid-generate-file $ENTRY:$SIZE --sid-list --sid-extension $YANG [-p $MODULES]

Where:

  • $ENTRY: Entry point of allocated YANG SID Range.
  • $SIZE: Size of allocated YANG SID Range.
  • $YANG: Path to the .yang data model file.
  • $MODULES: (Optional) Path to directories containing dependent YANG modules. Include with -p if your model requires additional modules.

Note: The range of 60,000 to 99,999 (size 40,000) is reserved for experimental YANG modules. The size of the SID range allocated for a YANG module is recommended to be a multiple of 50 and to be at least 33% above the current number of YANG items.

  • A YANG data model description JSON file (see samples/validation/description.json).
  • Dependencies:
    • cbor2

API and Usage

Import the module with:

import pycoreconf

ccm = pycoreconf.CORECONFModel(sid_files, model_description_file=None)

Create a CORECONF Model object with an associated YANG SID file.

  • sid_files: A list of path strings to one or more .sid files. Generate using ltn22/pyang module.
  • model_description_file: Optional model description file used for config validation.

ccm.add_modules_path(ietf_modules_loc)

  • ietf_modules_loc: Path or list of paths where IETF and other modules used in the YANG model may be found.

Returns nothing. Required for decoded configuration data validation.

ccm.toCORECONF(config)

  • config: Configuration data as a dict, JSON string, or path to a .json file.

Returns (CBOR encoded) CORECONF configuration data. Validates config data if a model description file has been provided.

ccm.toJSON(cbor_data, return_pydict=False)

  • cbor_data: (CBOR encoded) CORECONF configuration data.
  • return_pydict: Return data as a Python dictionary instead (useful if doing further processing or conversions to other formats)

Returns decoded configuration data as a JSON string (or Python dictionary). Validates config data if a model description file has been provided.

Other methods


ccm.validateConfig(config_data)

  • config_data: Python dictionary holding configuration data.

Returns True if input config data is valid according to the YANG data model. Returns False if the model's description file is not specified (unable to validate).

Config data is automatically validated during CORECONF/CBOR decoding.

ccm.lookupSID(config_pydict)

  • config_pydict: Python dictionary holding configuration data.

Returns a python dictionary with configuration keys/leaves substituted by their corresponding SID delta values.

ccm.lookupIdentifier(config_pydict)

  • config_pydict: Python dictionary holding configuration data, with SID delta values as keys.

Returns a python dictionary with SID delta keys substituted by their corresponding leaf identifiers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycoreconf-0.1.1.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycoreconf-0.1.1-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file pycoreconf-0.1.1.tar.gz.

File metadata

  • Download URL: pycoreconf-0.1.1.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for pycoreconf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d975194c4870dc2e5c82280e5b2c5466315048738a7ff1fbf6d5af390129e339
MD5 cf9a05b46a3694d94c5548c596fffbb1
BLAKE2b-256 c674061a94885ae846ae382792ddac8a881f483c76412a94db0ec42075aa0b8b

See more details on using hashes here.

File details

Details for the file pycoreconf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pycoreconf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for pycoreconf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35790ad3cbd62ef3c4076ddc1abff9eba8db1a60af791c28f37e0caec2ee5e72
MD5 abd1ccac0c0baec807a3a51ca599cd63
BLAKE2b-256 24a55b02b06508cdd7740c5fe23b841e3cc96623b5d49552ca525cd973c7f01c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page