{"library":"osc-lib","title":"OpenStackClient Plugin Library","description":"osc-lib is a Python library that provides common support modules for writing plugins for the OpenStackClient (OSC), the unified command-line client for OpenStack. It offers functionalities like command definitions, session management, and utility functions that plugin developers can leverage. The library is actively maintained and currently at version 4.4.0, with regular updates aligning with OpenStack development cycles.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install osc-lib"],"cli":null},"imports":["from osc_lib.command.command import Command","from osc_lib.session import Session","from osc_lib.api.api import APIClient","from osc_lib.api.auth import build_auth_plugins_option_parser","from osc_lib.utils import backward_compat_col_lister"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import argparse\nfrom osc_lib.command.command import Command\n\nclass MyCustomCommand(Command):\n    \"\"\"My custom OpenStackClient command.\"\"\"\n\n    def get_parser(self, prog_name):\n        parser = super(MyCustomCommand, self).get_parser(prog_name)\n        parser.add_argument(\n            'name',\n            metavar='<name>',\n            help='Name to greet'\n        )\n        return parser\n\n    def take_action(self, parsed_args):\n        # In a real OpenStackClient plugin, 'self.app' and 'self.client_manager'\n        # would provide access to OpenStack services and configuration.\n        # For this example, we'll simulate the output.\n        greeting = f\"Hello, {parsed_args.name}! This is a custom command from osc-lib.\"\n        return {}, {'Result': greeting}\n\n# Example of how to instantiate and call (for demonstration, not runnable without OSC context)\nif __name__ == '__main__':\n    # Simulate `app` and `app_args` that `cliff` (which OSC uses) would pass\n    class MockApp:\n        NAME = 'openstack'\n        def __init__(self):\n            self.options = argparse.Namespace()\n            self.options.debug = False\n    \n    class MockAppArgs:\n        pass\n\n    mock_app = MockApp()\n    mock_app_args = MockAppArgs()\n\n    cmd_instance = MyCustomCommand(mock_app, mock_app_args)\n    \n    # Simulate parsed arguments\n    parsed_args = cmd_instance.get_parser('my_command').parse_args(['World'])\n    \n    # Execute the command's action\n    # In a real setup, this would be called by the OpenStackClient framework\n    _columns, _data = cmd_instance.take_action(parsed_args)\n    print(f\"Command output: {_data['Result']}\")","lang":"python","description":"This quickstart demonstrates how to define a custom OpenStackClient command using `osc-lib`. It outlines extending `osc_lib.command.command.Command` to create a new CLI action, including argument parsing and action execution. Note that `osc-lib` is primarily for building plugins, so this code requires an OpenStackClient environment to run fully, but the example shows the core structure for plugin development. The `MockApp` and `MockAppArgs` classes are included to make the example runnable for demonstrating the `take_action` logic, though they don't replicate a full OpenStackClient runtime environment.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"4.0.2","pypi_latest":"4.6.0","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":8.6,"avg_import_s":0.19,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.18,"mem_mb":6.1,"disk_size":"95.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":8.3,"import_time_s":0.13,"mem_mb":6.1,"disk_size":"97M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.24,"mem_mb":7,"disk_size":"105.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":8.5,"import_time_s":0.21,"mem_mb":7,"disk_size":"107M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.2,"mem_mb":6.7,"disk_size":"105.2M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":8.2,"import_time_s":0.22,"mem_mb":6.7,"disk_size":"106M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.2,"mem_mb":7,"disk_size":"105.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":8,"import_time_s":0.19,"mem_mb":7,"disk_size":"106M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.15,"mem_mb":6.1,"disk_size":"98.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"osc-lib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":10.1,"import_time_s":0.14,"mem_mb":6.1,"disk_size":"99M"}]}}