Skip to main content

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:

pip install pynetcom

Development

To set up the development environment:

# 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:

    git clone https://github.com/ddarth/pynetcom.git
    cd pynetcom
    
  2. Set up a virtual environment:

    python -m venv .venv
    
  3. Activate the virtual environment:

    • On Windows:

      .venv\Scripts\activate
      
    • On macOS/Linux:

      source .venv/bin/activate
      
  4. Add your configuration data to config.py:

    cp examples/config.example.py examples/config.py
    vi examples/config.py
    
    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:

    python examples/huawei_nce.py
    

Usage

Here is an example of how to use the library:

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 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.

Metadata

Release files for pynetcom 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pynetcom 0.1.6
File Size Uploaded
pynetcom-0.1.6.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pynetcom 0.1.6
File Interpreter ABI Platform
pynetcom-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 32.9 kB

Release files / pynetcom-0.1.6.tar.gz

Download URL pynetcom-0.1.6.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
08bc7896ebd67f333803a7bf2cd9c70f0cc1a17c62c07e60a192be9e2312d82d
BLAKE2b-256 checksum
How to use checksums
7697adb610e826d94b2500cc0e0e4046dff7bfa8b9005a92ca47b6921e765696
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Release files / pynetcom-0.1.6-py3-none-any.whl

Download URL pynetcom-0.1.6-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7398553efefe230bb4688c83a35ab041ef86c1cd622dae83f1b1becbf7210ef
BLAKE2b-256 checksum
How to use checksums
5d036fd59785bd080f8cc203f2aedd4115b6eaf24577346cf2e14b07a0c34a66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page