Dell PowerStore Python Library
pypowerstore is the official Python library for interacting with Dell PowerStore storage arrays. It provides a programmatic interface to manage PowerStore resources like volumes, snapshots, hosts, and more. The current version is 3.4.2.0, with releases generally aligning with new PowerStore OS versions.
Common errors
-
requests.exceptions.SSLError: HTTPSConnectionPool(host='...', port=443): Max retries exceeded with url: /api/... (Caused by SSLError(CertificateError("hostname '...' doesn't match '...'")))cause SSL certificate verification failed, often due to self-signed certificates, untrusted CAs, or hostname mismatch.fixInitialize `PowerStoreClient` with `verify_ssl=False` (for development/testing only) or properly configure trusted certificates in your system or environment for production via `REQUESTS_CA_BUNDLE`. -
An error occurred: (401 Client Error: Unauthorized for url: https://...)
cause Incorrect username or password provided, or the user lacks sufficient API permissions on the PowerStore array.fixDouble-check the `username` and `password`. Verify the user has the required roles/permissions configured on the PowerStore array itself. -
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))cause Network connectivity issue between the client and the PowerStore array, or the PowerStore API service is unavailable.fixVerify network reachability to the PowerStore host/IP (ping, firewall rules). Check the PowerStore array's status and API service health. Ensure the correct port (443 by default) is open and accessible. -
An error occurred: (404 Client Error: Not Found for url: https://.../api/rest/v1/...) or (400 Client Error: Bad Request for url: https://.../api/rest/v1/...)
cause The requested API endpoint or resource does not exist, or the request body/parameters are invalid. This often indicates an API version mismatch between the library and PowerStore OS, or an incorrect API path/method.fixConfirm that the `pypowerstore` library version is compatible with your PowerStore OS version. Review the PowerStore API documentation for the correct endpoint paths and request formats specific to your PowerStore OS.
Warnings
- breaking Major versions of `pypowerstore` (e.g., 2.x to 3.x) are designed to correspond with specific PowerStore OS versions. Using a library version incompatible with your PowerStore OS can lead to API call failures or unexpected behavior due to schema or endpoint changes.
- gotcha SSL certificate verification is `True` by default, but many enterprise PowerStore deployments use self-signed certificates or internal CAs not trusted by default. The `verify_ssl=False` parameter is often used in examples for simplicity but is insecure for production.
- gotcha The PowerStore API requires specific user roles and permissions for certain operations. While an 'admin' user is often used in examples, in production, users with least privilege should be configured for security.
Install
-
pip install pypowerstore
Imports
- PowerStoreClient
from pypowerstore.client import PowerStoreClient
Quickstart
import os
from pypowerstore.client import PowerStoreClient
POWERSTORE_HOST = os.environ.get('POWERSTORE_HOST', 'your_powerstore_ip')
POWERSTORE_USER = os.environ.get('POWERSTORE_USER', 'admin')
POWERSTORE_PASSWORD = os.environ.get('POWERSTORE_PASSWORD', 'password')
if not all([POWERSTORE_HOST, POWERSTORE_USER, POWERSTORE_PASSWORD]):
print("Please set POWERSTORE_HOST, POWERSTORE_USER, and POWERSTORE_PASSWORD environment variables.")
exit(1)
# Initialize the client. For lab/dev environments, verify_ssl=False is common.
# For production, ensure proper SSL certificate handling by configuring trusted CAs.
client = PowerStoreClient(
host=POWERSTORE_HOST,
username=POWERSTORE_USER,
password=POWERSTORE_PASSWORD,
verify_ssl=False # Set to True and configure trusted CAs in production environments
)
try:
# Example: Get all systems
systems = client.system.get()
if systems:
print(f"Successfully connected to PowerStore: System ID: {systems[0]['id']}, Name: {systems[0]['name']}, Model: {systems[0]['model']}")
else:
print("No systems found.")
# Example: Get all volumes (if any exist)
volumes = client.volumes.get()
print(f"Found {len(volumes)} volumes.")
if volumes:
print(f"First volume ID: {volumes[0]['id']}, Name: {volumes[0]['name']}")
except Exception as e:
print(f"An error occurred: {e}")