Skip to main content

OpenStack client library with simplified authentication

Project description

osclient

OpenStack client library with simplified authentication and client management.

Features

  • Simplified OpenStack authentication using environment variables or direct parameters
  • Support for multiple OpenStack services (Nova, Keystone, Cinder, Neutron, Glance, Allocation)
  • Two authentication approaches: OpenStack (using keystoneauth1) and OpenStack2 (direct REST API)
  • Lazy loading of service clients

Installation

pip install osclient

Usage

Using OpenStack class (keystoneauth1-based)

from osclient import OpenStack

# Using environment variables
os_client = OpenStack()

# Or with explicit parameters
os_client = OpenStack(
    auth_url='https://keystone.example.com:5000/v3',
    project_id='your-project-id',
    username='your-username',
    password='your-password'
)

# Access service clients
servers = os_client.nova.servers.list()
images = os_client.glance.images.list()

Using OpenStack2 class (REST API-based)

from osclient import OpenStack2

os_client = OpenStack2(
    auth_url='https://keystone.example.com:5000/v3',
    project_name='your-project-name',
    username='your-username',
    password='your-password'
)

# Query services directly
servers = os_client.query('compute', 'servers')

Environment Variables

The library supports standard OpenStack environment variables:

  • OS_AUTH_URL
  • OS_PROJECT_ID or OS_TENANT_ID
  • OS_PROJECT_NAME or OS_TENANT_NAME
  • OS_USERNAME
  • OS_PASSWORD
  • OS_USER_DOMAIN_ID (defaults to 'default')
  • OS_PROJECT_DOMAIN_ID (defaults to 'default')

Requirements

  • Python 3.6+
  • keystoneauth1
  • python-novaclient
  • python-keystoneclient
  • python-cinderclient
  • python-neutronclient
  • nectarallocationclient
  • python-glanceclient
  • requests

Development

Building

To build the package, install the build dependencies and run:

# Install build dependencies
pip install build wheel

# Build source and wheel distributions
python -m build

This will create dist/ directory with both source distribution (.tar.gz) and wheel (.whl) files.

Alternatively, you can install the package in development mode:

pip install -e .

Testing

Install the development dependencies:

pip install -e ".[dev]"

Run the tests:

# Run all tests
pytest

# Run tests with coverage
pytest --cov=osclient --cov-report=html

# Run specific test file
pytest test/test_v1.py
pytest test/test_v2.py

Publishing

To publish the package to PyPI:

  1. Build the package (see Building section above)

  2. Install twine (if not already installed):

    pip install twine
    
  3. Upload to TestPyPI (recommended for first-time publishing):

    twine upload --repository testpypi dist/*
    
  4. Upload to PyPI:

    twine upload dist/*
    

    You will be prompted for your PyPI credentials. Alternatively, you can use an API token by setting:

    export TWINE_USERNAME=__token__
    export TWINE_PASSWORD=your_pypi_api_token
    

Note: Make sure to update the version number in both setup.py and pyproject.toml before publishing a new release.

License

MIT

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

osclient-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

osclient-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file osclient-0.1.0.tar.gz.

File metadata

  • Download URL: osclient-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.5

File hashes

Hashes for osclient-0.1.0.tar.gz
Algorithm Hash digest
SHA256 10945f3e04b9f574b1c594d0dc48fc4aecbb786e40b7771b56117c7474d4bda5
MD5 b6b9dc34e303208d54df7a7c255d2baf
BLAKE2b-256 fea4a6c0ef82c807e8f7b4c9b7237c33f376e2ded64ffc417701c29f5685dd8d

See more details on using hashes here.

File details

Details for the file osclient-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: osclient-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.5

File hashes

Hashes for osclient-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e55d415af844d5bf41964b6b48c4b713493579d07af6918b56636f1c48572b36
MD5 71440be5dfa4d6ea4353a182b9ee458f
BLAKE2b-256 a81f93df2375c816ea793f501992e9c1480f72e9cbfde74d16e6f76f5de00a2c

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