# PyNetCom
`pynetcom` is a library designed for connecting to network switches and routers from various vendors via REST API and CLI, as well as for interacting with management systems such as Huawei NCE and Nokia NSP. The library allows you to execute commands, retrieve inventory data, and obtain alarm lists.
## Features
- Connect to network devices using REST API and CLI.
- Interact with management systems (e.g., Huawei NCE, Nokia NSP).
- Retrieve inventory data.
- Obtain alarm lists.
- Convenient token management for authorization.
- Automatic token refresh upon expiration.
## Installation
You can install the package using `pip`:
```bash
pip install pynetcom
```
## Development
To set up the development environment:
```bash
# Install development dependencies
pip install setuptools wheel twine
# Install the package locally
pip install .
# Create wheel and source
pip install build twine
python -m build
```
## Running Examples
To run examples, follow these steps:
1. Clone the repository:
```bash
git clone https://github.com/ddarth/pynetcom.git
cd pynetcom
```
2. Set up a virtual environment:
```bash
python -m venv .venv
```
3. Activate the virtual environment:
- On Windows:
```bash
.venv\Scripts\activate
```
- On macOS/Linux:
```bash
source .venv/bin/activate
```
4. Add your configuration data to config.py:
```bash
cp examples/config.example.py examples/config.py
vi examples/config.py
```
```python
API_NCE_USER = "your_nce_api_user"
API_NCE_PASS = "your_nce_password"
API_NCE_HOST = "https://your_nce_hostip:26335"
API_NSP_USER = "your_nsp_api_user"
API_NSP_PASS = "your_nsp_password"
API_NSP_HOST = "https://your_nsp_host"
NETCONF_HOST = "192.168.0.1"
NETCONF_PORT = 830 # 22 for huawei
NETCONF_USER = "your_netconf_user"
NETCONF_PASSWORD = "yout_netconf_password"
```
5. Run an example script:
```bash
python examples/huawei_nce.py
```
## Usage
Here is an example of how to use the library:
```python
from pynetcom import RestNCE
# Initialize connection to NCE
nce = RestNCE(API_NCE_HOST, API_NCE_USER, API_NCE_PASS)
# Get subnets from NCE
nce.send_request("/restconf/v2/data/huawei-nce-resource-inventory:subnets")
items = nce.get_data()
print(items)
```
For additional info see examples/ folder
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Warning
Library use nsp_token.txt and nce_token.txt to store tokens.
Make sure that your have write permission to it.
Raw data
{
"_id": null,
"home_page": "https://github.com/ddarth/pynetcom",
"name": "pynetcom",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "networking huawei nokia rest cli netconf",
"author": "Dmitriy Kozlov",
"author_email": "kdsarts@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/22/f4/c64a4303794316ec02e95dafad24f7d6e3ffdb4b4adae400df790eceb883/pynetcom-0.1.5.tar.gz",
"platform": null,
"description": "# PyNetCom\r\n\r\n`pynetcom` is a library designed for connecting to network switches and routers from various vendors via REST API and CLI, as well as for interacting with management systems such as Huawei NCE and Nokia NSP. The library allows you to execute commands, retrieve inventory data, and obtain alarm lists.\r\n\r\n## Features\r\n\r\n- Connect to network devices using REST API and CLI.\r\n- Interact with management systems (e.g., Huawei NCE, Nokia NSP).\r\n- Retrieve inventory data.\r\n- Obtain alarm lists.\r\n- Convenient token management for authorization.\r\n- Automatic token refresh upon expiration.\r\n\r\n## Installation\r\n\r\nYou can install the package using `pip`:\r\n\r\n```bash\r\npip install pynetcom\r\n```\r\n\r\n## Development\r\n\r\nTo set up the development environment:\r\n\r\n```bash\r\n# Install development dependencies\r\npip install setuptools wheel twine\r\n\r\n# Install the package locally\r\npip install .\r\n\r\n# Create wheel and source \r\npip install build twine\r\npython -m build\r\n\r\n```\r\n\r\n## Running Examples\r\n\r\nTo run examples, follow these steps:\r\n\r\n1. Clone the repository:\r\n\r\n ```bash\r\n git clone https://github.com/ddarth/pynetcom.git\r\n cd pynetcom\r\n ```\r\n\r\n2. Set up a virtual environment:\r\n\r\n ```bash\r\n python -m venv .venv\r\n ```\r\n\r\n3. Activate the virtual environment:\r\n\r\n - On Windows:\r\n\r\n ```bash\r\n .venv\\Scripts\\activate\r\n ```\r\n\r\n - On macOS/Linux:\r\n\r\n ```bash\r\n source .venv/bin/activate\r\n ```\r\n\r\n4. Add your configuration data to config.py:\r\n ```bash\r\n cp examples/config.example.py examples/config.py\r\n vi examples/config.py\r\n ```\r\n ```python\r\n API_NCE_USER = \"your_nce_api_user\"\r\n API_NCE_PASS = \"your_nce_password\"\r\n API_NCE_HOST = \"https://your_nce_hostip:26335\"\r\n\r\n API_NSP_USER = \"your_nsp_api_user\"\r\n API_NSP_PASS = \"your_nsp_password\"\r\n API_NSP_HOST = \"https://your_nsp_host\"\r\n\r\n NETCONF_HOST = \"192.168.0.1\"\r\n NETCONF_PORT = 830 # 22 for huawei\r\n NETCONF_USER = \"your_netconf_user\"\r\n NETCONF_PASSWORD = \"yout_netconf_password\"\r\n ```\r\n\r\n5. Run an example script:\r\n\r\n ```bash\r\n python examples/huawei_nce.py\r\n ```\r\n\r\n\r\n## Usage\r\n\r\nHere is an example of how to use the library:\r\n\r\n```python\r\nfrom pynetcom import RestNCE\r\n\r\n# Initialize connection to NCE\r\nnce = RestNCE(API_NCE_HOST, API_NCE_USER, API_NCE_PASS)\r\n\r\n# Get subnets from NCE\r\nnce.send_request(\"/restconf/v2/data/huawei-nce-resource-inventory:subnets\")\r\nitems = nce.get_data()\r\nprint(items)\r\n```\r\nFor additional info see examples/ folder\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Warning\r\nLibrary use nsp_token.txt and nce_token.txt to store tokens.\r\nMake sure that your have write permission to it.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Library for Huawei, Nokia network device API interactions",
"version": "0.1.5",
"project_urls": {
"Homepage": "https://github.com/ddarth/pynetcom"
},
"split_keywords": [
"networking",
"huawei",
"nokia",
"rest",
"cli",
"netconf"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0dd40d7d5a289a2da0f8a57545b49d9889e1e3fee255f0d1ceec630cc03c1f2e",
"md5": "12d94ef68f214a7d231297b3643fa40a",
"sha256": "08ed843cec5b6f1f5590149ed06c9ffb47ddf5bef7fbd023c2dd4b23d5138f23"
},
"downloads": -1,
"filename": "pynetcom-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "12d94ef68f214a7d231297b3643fa40a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 15549,
"upload_time": "2025-07-31T10:28:03",
"upload_time_iso_8601": "2025-07-31T10:28:03.489810Z",
"url": "https://files.pythonhosted.org/packages/0d/d4/0d7d5a289a2da0f8a57545b49d9889e1e3fee255f0d1ceec630cc03c1f2e/pynetcom-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "22f4c64a4303794316ec02e95dafad24f7d6e3ffdb4b4adae400df790eceb883",
"md5": "c526ef96253ed87818d8085d9de65bc9",
"sha256": "a25f7e1540c73e50ee6f0ca13c2d14120def16fed3ea20563f0c582e5703ce8e"
},
"downloads": -1,
"filename": "pynetcom-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "c526ef96253ed87818d8085d9de65bc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 15106,
"upload_time": "2025-07-31T10:28:04",
"upload_time_iso_8601": "2025-07-31T10:28:04.458351Z",
"url": "https://files.pythonhosted.org/packages/22/f4/c64a4303794316ec02e95dafad24f7d6e3ffdb4b4adae400df790eceb883/pynetcom-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 10:28:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ddarth",
"github_project": "pynetcom",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": []
},
{
"name": "urllib3",
"specs": []
},
{
"name": "ncclient",
"specs": []
},
{
"name": "xmltodict",
"specs": []
},
{
"name": "pexpect",
"specs": []
}
],
"lcname": "pynetcom"
}