Skip to main content

Library for Huawei, Nokia network device API interactions

Project description

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

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

pynetcom-0.1.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

pynetcom-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pynetcom-0.1.2.tar.gz.

File metadata

  • Download URL: pynetcom-0.1.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for pynetcom-0.1.2.tar.gz
Algorithm Hash digest
SHA256 22dcaaa6727cf8853f5597f7b323eff048fa09b3ccf4203559f851bd77625316
MD5 6cd2f5638e008e7c31a05a25a47f4538
BLAKE2b-256 767c65b376841450667b895f8e46a5c40d08c74bda8b5d7fdda4d59e046ca244

See more details on using hashes here.

File details

Details for the file pynetcom-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pynetcom-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for pynetcom-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 918358ad4d80f0bc473db691f75f7acf5bb0ef2fa7f0f715d5753d8cf6f673bd
MD5 113a7d61abdaf3f68802dd4ace0a3375
BLAKE2b-256 7d3b4ffeda81bc2efcfcd9a93d2231daebdbf08e2d1c1bbda165ded1312e30c1

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