{"id":4729,"library":"python-openstackclient","title":"OpenStack Command-line Client","description":"OpenStackClient (OSC) is a command-line client for OpenStack that unifies the command sets for core services like Compute, Identity, Image, Network, Object Store, and Block Storage into a single shell with a uniform structure. It is currently at version 9.0.0 and aligns its release cadence with the broader OpenStack project releases, offering regular updates and support for new features.","status":"active","version":"9.0.0","language":"python","source_language":"en","source_url":"https://github.com/openstack/python-openstackclient","tags":["OpenStack","CLI","cloud","client","infrastructure"],"install":[{"cmd":"python3 -m pip install python-openstackclient","lang":"bash","label":"Install `python-openstackclient`"},{"cmd":"python3 -m pip install openstackclient","lang":"bash","label":"Recommended: Install `openstackclient` metapackage (includes plugins)"}],"dependencies":[{"reason":"The `openstackclient` package is a metapackage that installs `python-openstackclient` and a number of optional plugins, simplifying installation for a full CLI experience.","package":"openstackclient","optional":true}],"imports":[{"note":"`python-openstackclient` is primarily a command-line interface. Direct programmatic import of the `openstackclient` module for application logic is not the typical pattern. For Python API interactions, the `openstacksdk` library is recommended. If you need to execute CLI commands from Python, use `subprocess`.","wrong":"from openstackclient import Client","symbol":"openstack","correct":"import subprocess\n# ... or use openstacksdk for direct Python API interaction"}],"quickstart":{"code":"import os\nimport subprocess\n\n# --- Configuration (choose one method) ---\n# Method 1: Environment Variables (recommended for scripts)\nos.environ['OS_AUTH_URL'] = os.environ.get('OS_AUTH_URL', 'http://<your-keystone-url>/v3')\nos.environ['OS_USERNAME'] = os.environ.get('OS_USERNAME', 'admin')\nos.environ['OS_PASSWORD'] = os.environ.get('OS_PASSWORD', 'your_password')\nos.environ['OS_PROJECT_NAME'] = os.environ.get('OS_PROJECT_NAME', 'admin')\nos.environ['OS_USER_DOMAIN_NAME'] = os.environ.get('OS_USER_DOMAIN_NAME', 'Default')\nos.environ['OS_PROJECT_DOMAIN_NAME'] = os.environ.get('OS_PROJECT_DOMAIN_NAME', 'Default')\nos.environ['OS_IDENTITY_API_VERSION'] = os.environ.get('OS_IDENTITY_API_VERSION', '3')\n\n# Method 2: clouds.yaml (often found in ~/.config/openstack/clouds.yaml)\n# Ensure your clouds.yaml is configured and replace 'my-cloud' with your cloud name\n# If using clouds.yaml, you might not need to set environment variables.\n# Example clouds.yaml content (place in ~/.config/openstack/clouds.yaml or specify via OS_CLIENT_CONFIG_FILE):\n# clouds:\n#   my-cloud:\n#     auth:\n#       auth_url: 'http://<your-keystone-url>/v3'\n#       username: 'admin'\n#       password: 'your_password'\n#       project_name: 'admin'\n#       user_domain_name: 'Default'\n#       project_domain_name: 'Default'\n#     region_name: 'RegionOne'\n\n# Example: List OpenStack projects using the CLI\ntry:\n    print(\"\\n--- Listing OpenStack Projects ---\")\n    # Use 'openstack --os-cloud my-cloud project list' if using clouds.yaml\n    result = subprocess.run(['openstack', 'project', 'list'], capture_output=True, text=True, check=True)\n    print(result.stdout)\n    if result.stderr:\n        print(\"Stderr:\\n\", result.stderr)\n\n    print(\"\\n--- Listing OpenStack Services ---\")\n    result = subprocess.run(['openstack', 'service', 'list'], capture_output=True, text=True, check=True)\n    print(result.stdout)\n    if result.stderr:\n        print(\"Stderr:\\n\", result.stderr)\n\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error executing OpenStack CLI command: {e.cmd}\")\n    print(f\"Return Code: {e.returncode}\")\n    print(f\"Stdout:\\n{e.stdout}\")\n    print(f\"Stderr:\\n{e.stderr}\")\nexcept FileNotFoundError:\n    print(\"Error: 'openstack' command not found. Is OpenStackClient installed and in your PATH?\")\n","lang":"python","description":"This quickstart demonstrates how to interact with the OpenStack CLI programmatically from Python using `subprocess`. It shows two common authentication methods: environment variables (often sourced from an `openrc` file) and `clouds.yaml`. Ensure your OpenStack credentials are set as environment variables or configured in a `clouds.yaml` file for the client to authenticate successfully."},"warnings":[{"fix":"Ensure your environment uses Python 3.10 or higher. Use `python3 -m pip install ...`.","message":"Python 2.x is no longer supported. `python-openstackclient` 9.0.0 requires Python >=3.10. Older versions of the client (especially pre-3.x) might have exhibited syntax errors if run with Python 2.","severity":"breaking","affected_versions":"<9.0.0"},{"fix":"For a full suite of commands, `pip install openstackclient` is generally preferred.","message":"There are two PyPI packages: `python-openstackclient` (the core client) and `openstackclient` (a metapackage that installs `python-openstackclient` and common plugins). The latter is often recommended for a more complete experience.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prefer using `openstack <service> <command>` (e.g., `openstack server list`) over legacy commands (e.g., `nova list`). Refer to documentation for equivalent commands.","message":"Legacy project-specific command-line clients (e.g., `nova`, `glance`, `cinder` CLIs) are being actively superseded by `python-openstackclient` for a unified experience. Some advanced or less common features might still exist only in the legacy clients but are being migrated.","severity":"deprecated","affected_versions":"All versions (ongoing transition)"},{"fix":"Always use Python virtual environments (`python3 -m venv .venv` and `source .venv/bin/activate`) when installing packages with `pip` to isolate dependencies.","message":"Installing Python packages directly into the system's Python environment using `pip install` without a virtual environment can lead to conflicts and break system tools.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure one of the authentication methods is correctly configured. For `clouds.yaml`, it's typically located at `~/.config/openstack/clouds.yaml` or specified via `OS_CLIENT_CONFIG_FILE`. Verify settings like `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, `OS_PROJECT_NAME`, etc.","message":"Authentication can be configured via environment variables (e.g., sourcing an `openrc` file), a `clouds.yaml` file, or command-line options. Inconsistent or missing authentication details are a common source of errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'9.0.0':47 'align':49 'block':32 'broader':55 'cadenc':52 'cli':68 'client':5,13,70 'cloud':69 'command':3,11,19 'command-lin':2,10 'comput':25 'core':22 'current':44 'featur':66 'ident':26 'imag':27 'infrastructur':71 'like':24 'line':4,12 'network':28 'new':65 'object':29 'offer':59 'openstack':1,15,56,67 'openstackcli':6 'osc':7 'project':57 'regular':60 'releas':51,58 'servic':23 'set':20 'shell':37 'singl':36 'storag':33 'store':30 'structur':41 'support':63 'unifi':17 'uniform':40 'updat':61 'version':46","created_at":"2026-04-12T14:05:06.999815+00:00","updated_at":"2026-04-16T20:26:51.637360+00:00","problems":[{"fix":"Verify that your OpenStack environment variables (`OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, `OS_PROJECT_NAME`, `OS_REGION_NAME`) or `clouds.yaml` entries are correctly configured and match your OpenStack cloud's authentication requirements.","cause":"This error indicates that the provided credentials (username, password, or token) are incorrect, expired, or lack the necessary permissions to authenticate with the OpenStack Identity service (Keystone).","error":"ERROR (Unauthorized): The request you have made requires authentication."},{"fix":"Check your network connectivity to the OpenStack API endpoint, verify that the `OS_AUTH_URL` environment variable or the endpoint in `clouds.yaml` is correct, and ensure that the OpenStack Identity service (Keystone) is running and accessible.","cause":"This is a network error indicating that the OpenStack API endpoint the client is trying to reach is unreachable, either due to network connectivity issues, an incorrect URL, or the OpenStack service not running.","error":"ERROR (ConnectionRefusedError): Could not connect to host <hostname>:<port>."},{"fix":"Set the `OS_PROJECT_NAME` (or `OS_TENANT_NAME`) and `OS_PROJECT_DOMAIN_NAME` (if applicable) environment variables, or ensure that `project_name` and `project_domain_name` are correctly specified in your `clouds.yaml` configuration.","cause":"OpenStack authentication often requires a specific project (tenant) or domain scope, and this error occurs when `OS_PROJECT_NAME`, `OS_PROJECT_ID`, `OS_DOMAIN_NAME`, or `OS_DOMAIN_ID` is missing or incorrect in your configuration.","error":"ERROR (CommandError): You must provide a project or domain to authenticate."},{"fix":"Verify that the cloud name specified (e.g., `mycloud`) matches an existing entry in your `clouds.yaml` file, or ensure the `OS_CLOUD` environment variable is correctly set to a valid cloud configuration.","cause":"This error occurs when the `openstack` command is invoked with `--os-cloud <name>` or the `OS_CLOUD` environment variable is set to a cloud name that does not exist in your `~/.config/openstack/clouds.yaml` file or is not configured via environment variables.","error":"ERROR (ConfigException): No cloud named 'mycloud' found in clouds.yaml or envvars"},{"fix":"Verify that your `OS_AUTH_URL` environment variable points to a valid OpenStack Identity service endpoint, and ensure that the OpenStack services you are trying to access are running and their endpoints are correctly registered in Keystone's service catalog.","cause":"This error indicates that the OpenStackClient failed to discover the available API versions for a service, often due to an incorrect `OS_AUTH_URL` or issues with the service catalog provided by the Identity service (Keystone).","error":"ERROR (DiscoveryFailure): Could not discover appropriate API version"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"10.3.0","cli_name":"openstack","cli_version":null,"type":"library","homepage":"https://docs.openstack.org/python-openstackclient/","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/python-openstackclient/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"failing","verified_at":null,"last_verified":"2026-08-30","next_check":"2026-07-11","install_tag":null}}