Registry / aws / apache-libcloud

apache-libcloud

JSON →
library3.9.0pypypi✓ verified 35d ago

Apache Libcloud is a standard Python library that abstracts away differences among multiple cloud provider APIs, offering a unified interface to manage various cloud resources like servers, object storage, load balancers, and DNS. The current version is 3.9.0. The project follows an event-driven release schedule, with new versions released as enough changes accumulate, or for critical bug and security fixes.

awsgcpazuredevops
Install & Compatibility
Where this runs
tested against v3.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.626s · 56.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.6s · import 0.586s · 57MB
56MB installed
● package 56MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Import specific cloud provider types from the relevant service module (e.g., compute, storage, dns).

from libcloud.compute.types import Provider

Use 'get_driver' from the 'providers' submodule of the desired service API.

from libcloud.compute.providers import get_driver

This quickstart demonstrates how to connect to a cloud provider (Rackspace in this example) using the Libcloud Compute API. It shows how to obtain a driver, authenticate using environment variables, and list available server sizes and images. Remember to replace placeholder credentials with your actual API keys and username, preferably loaded from environment variables for security.

import os from libcloud.compute.types import Provider from libcloud.compute.providers import get_driver # Set your credentials using environment variables for security RACKSPACE_USER = os.environ.get('RACKSPACE_USERNAME', 'your_username') RACKSPACE_API_KEY = os.environ.get('RACKSPACE_API_KEY', 'your_api_key') if RACKSPACE_USER == 'your_username' or RACKSPACE_API_KEY == 'your_api_key': print("Please set RACKSPACE_USERNAME and RACKSPACE_API_KEY environment variables.") exit(1) # Obtain a reference to the Rackspace Compute driver cls = get_driver(Provider.RACKSPACE) driver = cls(RACKSPACE_USER, RACKSPACE_API_KEY, region='iad') # 'iad' for US-East (Virginia) print("Connected to Rackspace Compute service.") # List available sizes (flavors) print("Available sizes:") sizes = driver.list_sizes() for size in sizes: print(f" - {size.id}: {size.name} ({size.ram}MB RAM, {size.disk}GB Disk)") # List available images print("Available images:") images = driver.list_images() for image in images: print(f" - {image.id}: {image.name}") # Example: Select a size and image for node creation (adjust as needed) # This is a placeholder and might require matching a specific image/size from your account/region # For Rackspace, a common base image might be 'Ubuntu 18.04' or similar. # For size, 'performance1-1' (1GB RAM) is common. selected_size = next((s for s in sizes if s.id == 'performance1-1'), None) selected_image = next((i for i in images if 'Ubuntu 18.04' in i.name), None) if selected_size and selected_image: print(f"Attempting to create node with size: {selected_size.name} and image: {selected_image.name}") # Note: Creating a node usually incurs cost. This part is commented out. # try: # node = driver.create_node(name='libcloud-test-node', size=selected_size, image=selected_image) # print(f"Node created: {node.name} (ID: {node.id}, State: {node.state})") # except Exception as e: # print(f"Error creating node: {e}") else: print("Could not find suitable size or image for node creation. Please check available options.")
Debug
Known footguns
breakingLibcloud 3.9.0 (and newer) has significantly narrowed its Python version support. It now officially requires Python >= 3.10. Support for Python 3.9, 3.8, and 3.7 has been explicitly dropped in recent 3.x releases.
breakingSeveral compute drivers for defunct or non-offering providers were removed in Libcloud 3.8.0. If you are upgrading from an older version and using one of these providers, your code will break.
gotchaHardcoding API credentials directly in your code is a security risk. It's a common mistake that leads to credential exposure.
gotchaIn older versions (prior to 0.4.2), Libcloud did not validate host SSL certificates by default, making applications vulnerable to Man-in-the-Middle attacks.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
21 hits · last 30 days
gptbot
4
amazonbot
4
ahrefsbot
3
dotbot
2
script
1
Resources