Registry / devops / softlayer

softlayer

JSON →
library6.2.9pypypi✓ verified 33d ago

The `softlayer-python` library provides both a Python API client and a command-line interface (CLI) for interacting with the IBM Cloud SoftLayer API. It abstracts the complexities of the SOAP/REST API, allowing developers to manage SoftLayer resources such as virtual servers, bare metal, storage, and networking. The current version is 6.2.9, and the project maintains an active release cadence with frequent minor updates and bug fixes.

devopshttp-networking
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

from SoftLayer import Client
from SoftLayer import API
from SoftLayer import CLI

This quickstart demonstrates how to initialize the SoftLayer client using environment variables for authentication and retrieve basic account information. It also shows an example of fetching virtual guests, highlighting the use of 'object masks' which are fundamental for getting detailed API responses.

import SoftLayer import os # SoftLayer API credentials can be set as environment variables (SL_USERNAME, SL_API_KEY) # or passed directly. Environment variables are recommended for security. # SL_ENDPOINT_URL is optional, defaults to 'api.softlayer.com/rest/v3.1' client = SoftLayer.Client( username=os.environ.get('SL_USERNAME', 'YOUR_USERNAME'), api_key=os.environ.get('SL_API_KEY', 'YOUR_API_KEY'), endpoint_url=os.environ.get('SL_ENDPOINT_URL') ) try: # Example: Get the account details account = client['Account'].getObject() print(f"Successfully connected to SoftLayer. Account ID: {account['id']}, Company: {account['companyName']}") # Example: List up to 5 virtual guests (VMs) # Object masks are crucial for retrieving full data mask = 'mask[id, hostname, domain, primaryIpAddress, primaryBackendIpAddress]' vms = client['Account'].getVirtualGuests(mask=mask, limit=5) if vms: print("\nVirtual Guests (first 5):") for vm in vms: print(f"- ID: {vm.get('id')}, Hostname: {vm.get('hostname')}, IP: {vm.get('primaryIpAddress')}") else: print("\nNo virtual guests found.") except SoftLayer.exceptions.SoftLayerAPIError as e: print(f"Error connecting to SoftLayer API: {e}") print("Please ensure your SL_USERNAME and SL_API_KEY environment variables are correct.") except Exception as e: print(f"An unexpected error occurred: {e}")
slcli --version
Debug
Known footguns
breakingCDN (Content Delivery Network) commands were removed from the `slcli` (SoftLayer CLI) and the underlying API methods were deprecated.
breakingThe method for finding a VLAN's datacenter via `Vlan.primaryRouter` was migrated.
gotchaSoftLayer API calls often return only partial data for objects by default. To retrieve full details (e.g., IP addresses, hardware components for a server), you must specify an 'object mask'.
gotchaWhen fetching large lists of objects (e.g., `getAllObjects`), the API often uses pagination. Incomplete results or unexpected behavior can occur if not handled correctly.
gotchaAuthentication can be configured via `~/.softlayer` config file, environment variables (`SL_USERNAME`, `SL_API_KEY`, `SL_ENDPOINT_URL`), or direct arguments to `SoftLayer.Client`.
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
0 hits · last 30 days

No traffic data recorded yet.

Resources