{"library":"python-octaviaclient","title":"Octavia Client for OpenStack Load Balancing","description":"The `python-octaviaclient` library provides a client for interacting with the OpenStack Octavia Load Balancing service API (primarily v2). It allows users to programmatically manage load balancers, listeners, pools, members, and health monitors within an OpenStack environment. The current version is 3.13.0, and releases generally follow OpenStack development cycles, with patch releases occurring as needed.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install python-octaviaclient"],"cli":{"name":"openstack","version":"openstack 9.0.0"}},"imports":["from octaviaclient.v2.client import Client","from keystoneauth1.session import Session","from keystoneauth1.adapter import Adapter"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom keystoneauth1.identity import v3\nfrom keystoneauth1.session import Session\nfrom keystoneauth1.adapter import Adapter\nfrom octaviaclient.v2.client import Client\n\n# Set OpenStack authentication environment variables (e.g., OS_AUTH_URL, OS_USERNAME, OS_PASSWORD, etc.)\n# Or directly provide credentials\n\nauth = v3.Password(\n    auth_url=os.environ.get('OS_AUTH_URL', 'http://localhost:5000/v3'),\n    username=os.environ.get('OS_USERNAME', 'admin'),\n    password=os.environ.get('OS_PASSWORD', 'password'),\n    project_name=os.environ.get('OS_PROJECT_NAME', 'admin'),\n    user_domain_name=os.environ.get('OS_USER_DOMAIN_NAME', 'Default'),\n    project_domain_name=os.environ.get('OS_PROJECT_DOMAIN_NAME', 'Default')\n)\nsess = Session(auth=auth)\n\n# Create an Octavia client adapter\noctavia_client = Client(\n    session=sess,\n    region_name=os.environ.get('OS_REGION_NAME', None),\n    service_type='load-balancer',\n    interface='public'\n)\n\ntry:\n    # Example: List all load balancers\n    load_balancers = octavia_client.loadbalancer.list()\n    print(f\"Found {len(load_balancers)} load balancers:\")\n    for lb in load_balancers:\n        print(f\"  - ID: {lb['id']}, Name: {lb['name']}, Provisioning Status: {lb['provisioning_status']}\")\nexcept Exception as e:\n    print(f\"Error connecting to Octavia or listing load balancers: {e}\")\n    print(\"Please ensure your OpenStack environment variables are correctly set.\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the Octavia client using Keystone v3 authentication, retrieve an authenticated session, and then list existing load balancers. It relies on standard OpenStack environment variables for credentials. Ensure these are set or replace `os.environ.get` calls with your specific values.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}