Chameleon Cloud Python API

python-chi is a Python library that can help you interact with the Chameleon testbed to improve your workflows with automation. It additionally pairs well with environments like Jupyter Notebooks.

Installation

https://img.shields.io/pypi/v/python-chi
pip install python-chi

Authentication

Environment variables are the primary authentication method. Please refer to the documentation on OpenRC scripts to learn more about how to download and source your authentication credentials for the CLI; the same instructions apply for using the Python interface.

Depending on the contents of your OpenRC script, you might need to include this line in your python script:

chi.set('project_domain_name', 'chameleon')

Basic usage

The following example shows how to make a reservation for a bare metal server. For more details about the modules available refer to their respective pages.

import chi

# Select your project
chi.set('project_name', 'CH-XXXXXX')
# Select your site
chi.use_site('CHI@UC')

# Make a reservation ...
reservations = []
# ... for one node of type "compute_skylake"
chi.lease.add_node_reservation(
    reservations, node_type='compute_skylake', count=1)
# ... and one Floating IP
chi.lease.add_fip_reservation(count=1)
# ... for one day.
start_date, end_date = chi.lease.lease_duration(days=1)
chi.lease.create_lease(
    lease_name, reservations, start_date=start_date, end_date=end_date)

Indices and tables