A Python library for cloudscale.ch, requires Python 3.10 or newer.
pip install -U cloudscale-sdkfrom cloudscale import Cloudscale
with Cloudscale(api_token="...") as cloudscale:
server = cloudscale.server.create(
name="db-master", flavor="flex-4", image="debian-12"
)
cloudscale.server.stop(uuid=server["uuid"])
for volume in cloudscale.volume.get_all(filter_tag="project=apollo"):
print(volume["name"])Resources available as attributes: custom_image, flavor, floating_ip, image,
network, objects_user, region, server, server_group, subnet, volume.
Depending on the resource they offer get_all(), get_by_uuid(), create(),
update() and delete().
Errors are raised as CloudscaleException (configuration problems) and
CloudscaleApiException (API errors, carrying status_code and response).
The API token is taken from the api_token argument, or from a cloudscale.ini
looked up in this order, later files winning:
$XDG_CONFIG_HOME/cloudscale/cloudscale.ini(~/.config/...by default)~/.cloudscale.ini./cloudscale.ini
[default]
api_token = ...
[production]
api_token = ...
timeout = 30Select a section with Cloudscale(profile="production") or $CLOUDSCALE_PROFILE.
| Variable | Description |
|---|---|
CLOUDSCALE_API_URL |
API endpoint, defaults to https://api.cloudscale.ch/v1 |
CLOUDSCALE_CONFIG |
Config file name, defaults to cloudscale.ini |
CLOUDSCALE_PROFILE |
Config section to use, defaults to default |
CLOUDSCALE_LOG_LEVEL |
Log level, defaults to ERROR |
This project uses uv and ruff.
make install # create the virtualenv
make test # run the tests
make coverage # run the tests with a coverage report
make lint # lint and format check
make format # apply lint fixes and formatting