# pycoreconf
Open-source implementation library of CORECONF (CoAP Management Interface) for Python.
## What is CORECONF?
The [CoAP Management Interface (CORECONF)](https://datatracker.ietf.org/doc/html/draft-ietf-core-comi-11) 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](https://www.rfc-editor.org/rfc/rfc7950) 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)](200~https://datatracker.ietf.org/doc/html/draft-ietf-core-sid-15). 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](https://github.com/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-extention $YANG -p $MODULES
```
Where:
- `$ENTRY`: Entry point of allocated YANG SID Range.
- `$SIZE`: Size of allocated YANG SID Range.
- `$YANG`: .yang data model file.
- `$MODULES`: path to yang modules (pyang/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_file, model_description_file=None)`
Create a CORECONF Model object with an associated YANG SID file.
- `sid_file`: Path to model's .sid file. Generated using [ltn22/pyang](https://github.com/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_json)`
- `config_json`: JSON object or file containing configuration data.
Returns (CBOR encoded) CORECONF configuration data.
### `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 object (or Python dictionary). Validates config data if a model description file has been set.
### 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/alex-fddz/pycoreconf",
"name": "pycoreconf",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.7",
"maintainer_email": null,
"keywords": "coreconf, comi, coap, yang",
"author": "Javier A. Fernandez",
"author_email": "javier.fddz@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/aa/45/748a31d3a368fe261804dc76e4b39c7a9a3873d663785013f77cd841292e/pycoreconf-0.0.6.tar.gz",
"platform": null,
"description": "# pycoreconf\n\nOpen-source implementation library of CORECONF (CoAP Management Interface) for Python.\n\n## What is CORECONF?\n\nThe [CoAP Management Interface (CORECONF)](https://datatracker.ietf.org/doc/html/draft-ietf-core-comi-11) 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](https://www.rfc-editor.org/rfc/rfc7950) data model.\n\nCORECONF uses a CBOR mapping of YANG to keep message sizes extremely low, and substitutes the nodes' names for [YANG Schema Item iDentifiers (SIDs)](200~https://datatracker.ietf.org/doc/html/draft-ietf-core-sid-15). 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.\n\n## Installation\n\nFrom PyPI:\n\n```\npip install pycoreconf\n```\n\nFrom source:\n\n```\ngit clone https://github.com/alex-fddz/pycoreconf.git\ncd pycoreconf\npython3 setup.py install # this might require root access\n```\n\n### To uninstall\n\n```\npip uninstall pycoreconf\n```\n\n## Requirements & Setup\n\n- [ltn22/pyang](https://github.com/ltn22/pyang/) module. Allows the generation of the model's SID file including leaves' data types. Provides YANG IETF modules necessary for config validation.\n- SID file generated as follows (see `tools/gen_sid.sh`):\n\n```\npyang --sid-generate-file $ENTRY:$SIZE --sid-list --sid-extention $YANG -p $MODULES\n```\n\nWhere:\n- `$ENTRY`: Entry point of allocated YANG SID Range.\n- `$SIZE`: Size of allocated YANG SID Range.\n- `$YANG`: .yang data model file.\n- `$MODULES`: path to yang modules (pyang/modules/)\n\n> *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.\n\n- A YANG data model description JSON file (see `samples/validation/description.json`).\n- Dependencies:\n - `cbor2`\n\n## API and Usage\n\nImport the module with:\n\n```\nimport pycoreconf\n```\n\n### `ccm = pycoreconf.CORECONFModel(sid_file, model_description_file=None)`\n\nCreate a CORECONF Model object with an associated YANG SID file.\n\n- `sid_file`: Path to model's .sid file. Generated using [ltn22/pyang](https://github.com/ltn22/pyang/) module.\n- `model_description_file`: Optional model description file. Used for config validation.\n\n### `ccm.add_modules_path(ietf_modules_loc)`\n\n- `ietf_modules_loc`: Path or list of paths where IETF and other modules used in the YANG model may be found.\n\nReturns nothing. Required for decoded configuration data validation.\n\n### `ccm.toCORECONF(config_json)` \n\n- `config_json`: JSON object or file containing configuration data.\n\nReturns (CBOR encoded) CORECONF configuration data.\n\n### `ccm.toJSON(cbor_data, return_pydict=False)`\n\n- `cbor_data`: (CBOR encoded) CORECONF configuration data.\n- `return_pydict`: Return data as a Python dictionary instead (useful if doing further processing or conversions to other formats)\n\nReturns decoded configuration data as a JSON object (or Python dictionary). Validates config data if a model description file has been set.\n\n### Other methods\n---\n\n### `ccm.validateConfig(config_data)`\n\n- `config_data`: Python dictionary holding configuration data.\n\nReturns `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).\n\nConfig data is automatically validated during CORECONF/CBOR decoding.\n\n### `ccm.lookupSID(config_pydict)`\n\n- `config_pydict`: Python dictionary holding configuration data.\n\nReturns a python dictionary with configuration keys/leaves substituted by their corresponding SID delta values.\n\n### `ccm.lookupIdentifier(config_pydict)`\n\n- `config_pydict`: Python dictionary holding configuration data, with SID delta values as keys.\n\nReturns a python dictionary with SID delta keys substituted by their corresponding leaf identifiers.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "open-source implementation of CORECONF (CoAP Management Interface)",
"version": "0.0.6",
"project_urls": {
"Bug Tracker": "https://github.com/alex-fddz/pycoreconf/issues",
"Homepage": "https://github.com/alex-fddz/pycoreconf",
"Source Code": "https://github.com/alex-fddz/pycoreconf"
},
"split_keywords": [
"coreconf",
" comi",
" coap",
" yang"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1d70494ba6fe2a845301792a58619b50ddfe84ddeda68843d3be33a103394921",
"md5": "2f713527e36c039196089799fdb1c50e",
"sha256": "f4fbcb2878e42333a894153de2a7b938e894622a9283bd4a1780ad2874c5d79e"
},
"downloads": -1,
"filename": "pycoreconf-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2f713527e36c039196089799fdb1c50e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.7",
"size": 19160,
"upload_time": "2024-03-29T11:26:54",
"upload_time_iso_8601": "2024-03-29T11:26:54.432510Z",
"url": "https://files.pythonhosted.org/packages/1d/70/494ba6fe2a845301792a58619b50ddfe84ddeda68843d3be33a103394921/pycoreconf-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa45748a31d3a368fe261804dc76e4b39c7a9a3873d663785013f77cd841292e",
"md5": "c7331390c02f376c1b3ae07cb65f9db1",
"sha256": "98a65851866f4800294116fcbd37f17f4eb72ff97eb4340cb127f516aa1a9019"
},
"downloads": -1,
"filename": "pycoreconf-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "c7331390c02f376c1b3ae07cb65f9db1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.7",
"size": 18781,
"upload_time": "2024-03-29T11:26:55",
"upload_time_iso_8601": "2024-03-29T11:26:55.595877Z",
"url": "https://files.pythonhosted.org/packages/aa/45/748a31d3a368fe261804dc76e4b39c7a9a3873d663785013f77cd841292e/pycoreconf-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-29 11:26:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alex-fddz",
"github_project": "pycoreconf",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pycoreconf"
}