Skip to main content

Modern async Python client for Calix Management System NBI

Project description

CMS-NBI-CLIENT

CI Python Version License

Modern async Python client for Calix Management System (CMS) Northbound Interface (NBI) with full HTTPS support, connection pooling, circuit breakers, and structured logging.

Note: This package is not owned, supported, or endorsed by Calix. It's an independent implementation for interacting with CMS NBIs.

Features

  • Modern Async/Await: Built on aiohttp for high-performance async operations
  • HTTPS Support: Full TLS/SSL support with certificate validation
  • Connection Pooling: Reuse connections for better performance
  • Circuit Breaker: Automatic failure detection and recovery
  • Structured Logging: Rich logs with structlog for better debugging
  • Type Safety: Full type hints and Pydantic validation
  • Secure Storage: Encrypted credential storage using system keyring
  • XML Security: Protection against XXE and other XML attacks
  • Comprehensive Testing: High test coverage with pytest
  • Backward Compatible: Sync wrapper for legacy code

Quick Start

Installation

pip install cms-nbi-client

Basic Usage

import asyncio
from cmsnbiclient import CMSClient, Config

# Modern async usage
async def main():
    config = Config(
        credentials={
            "username": "your_username",
            "password": "your_password"
        },
        connection={
            "host": "cms.example.com"
        }
    )
    
    async with CMSClient(config) as client:
        # Create ONT
        result = await client.e7.create_ont(
            network_name="NTWK-1",
            ont_id="123",
            admin_state="enabled"
        )
        print(result)

# Run async code
asyncio.run(main())

# Synchronous usage (backward compatible)
with CMSClient.sync(config) as client:
    result = client.e7.query_ont(
        network_name="NTWK-1",
        ont_id="123"
    )
    print(result)

Configuration

Configuration can be provided via:

  • Direct instantiation
  • Environment variables
  • Configuration files (JSON/YAML)
# Environment variables
export CMS_USERNAME=your_username
export CMS_PASSWORD=your_password
export CMS_CONNECTION__HOST=cms.example.com
export CMS_CONNECTION__VERIFY_SSL=true

# From file
config = Config.from_file("config.yaml")

Advanced Features

Connection Pooling

config = Config(
    performance={
        "connection_pool_size": 100,
        "max_concurrent_requests": 50
    }
)

Circuit Breaker

config = Config(
    performance={
        "enable_circuit_breaker": True,
        "circuit_breaker_threshold": 5,
        "circuit_breaker_timeout": 60
    }
)

Structured Logging

from cmsnbiclient import setup_logging

# JSON logs for production
setup_logging(log_level="INFO", json_logs=True)

# Pretty logs for development
setup_logging(log_level="DEBUG", json_logs=False)

Documentation

For detailed documentation and examples, see the /Examples folder.

Available Operations

E7 Operations

  • Create: ONT, VLAN, VLAN Members, Ethernet Services
  • Delete: ONT, VLAN, VLAN Members, Ethernet Services
  • Query: System info, ONT profiles, VLANs, DHCP leases
  • Update: ONT configuration, Ethernet services

REST Operations

  • Device queries
  • System information

Development

Setup Development Environment

# Install poetry
pip install poetry

# Install dependencies
poetry install

# Run tests
poetry run pytest

# Run linting
poetry run black .
poetry run isort .
poetry run flake8
poetry run mypy .

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

Resources

Official Calix Documentation

Authors

License

GPL-3.0

Changelog

See CHANGELOG.md for version history.

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

cms_nbi_client-2.0.0.tar.gz (57.9 kB view details)

Uploaded Source

Built Distribution

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

cms_nbi_client-2.0.0-py3-none-any.whl (68.0 kB view details)

Uploaded Python 3

File details

Details for the file cms_nbi_client-2.0.0.tar.gz.

File metadata

  • Download URL: cms_nbi_client-2.0.0.tar.gz
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for cms_nbi_client-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6e3f0fa0dbea52decf4cf74e8dd0661c495650e3a9d4d2d91ff41cbdb8472587
MD5 0ae5511fbb36c82caeaa41728eb01acb
BLAKE2b-256 e68a942f6a6d226a196398fc682e314110f9b1158475536b126770de72b709bb

See more details on using hashes here.

File details

Details for the file cms_nbi_client-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: cms_nbi_client-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 68.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for cms_nbi_client-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c820c96ecf732ea8a137f5d3a306f770e173ca99d2de99df8c42dbf4e41c6935
MD5 413f90fd0c5ec164d679f167303425c3
BLAKE2b-256 95c60df5f225e52f3b30f6c579447e71fe16cd933df3b2f934fee0f59c89d46e

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