API reference#
Python API for plugin authors and advanced users. All symbols are importable from the modules listed below.
kiso.utils#
Ansible helpers#
run_ansible#
def run_ansible(playbooks, roles=None, extra_vars=None, ...) -> None
Run one or more Ansible playbooks against provisioned roles. Wraps enoslib.run_ansible with on_error_continue=True — task errors are logged but do not abort execution.
See the EnOSlib run_ansible docs for the full parameter list.
actions#
def actions(roles=None, ...) -> contextmanager
Context manager that builds and runs a sequence of Ansible tasks against provisioned roles. Wraps enoslib.actions with on_error_continue=True — task errors are logged but do not abort execution.
See the EnOSlib actions docs for the full parameter list.
Role and label helpers#
resolve_labels#
def resolve_labels(labels: Roles, label_names: list[str]) -> Roles
Parameter |
Type |
Description |
|---|---|---|
|
|
Collection of labels to resolve from |
|
|
Label names to filter or combine; empty list returns the original |
Returns a Roles object. Multiple names are merged with a logical OR.
split_labels#
def split_labels(split: Roles, labels: Roles) -> tuple[Roles, Roles]
Splits split into (non-edge VMs, edge containers) using labels["chameleon-edge"] as the separator.
Parameter |
Type |
Description |
|---|---|---|
|
|
Complete label set to split |
|
|
Reference label set containing the |
Returns (vms, containers).
IP helpers#
get_ips#
def get_ips(machine: Host | ChameleonDevice) -> list[tuple[IPv4Address | IPv6Address, int]]
Returns all non-loopback, non-link-local IP addresses for a machine, sorted by priority.
Priority |
Address type |
|---|---|
|
Public IPv4 |
|
Public IPv6 |
|
Private IPv4 |
|
Private IPv6 |
Floating IPs stored in machine.extra["floating-ips"] are included.
kiso.schema#
JSON schema objects used for experiment config validation. Schemas are assembled at import time from all registered plugins.
Name |
Description |
|---|---|
|
Reusable sub-schemas: |
Use $ref to pull individual COMMONS_SCHEMA definitions into a plugin schema:
MY_SCHEMA = {
"type": "object",
"properties": {
"labels": {"$ref": "py-obj:kiso.schema.COMMONS_SCHEMA#/$defs/labels"},
"variables": {"$ref": "py-obj:kiso.schema.COMMONS_SCHEMA#/$defs/variables"},
"script": {"$ref": "py-obj:kiso.schema.COMMONS_SCHEMA#/$defs/script"},
"location": {"$ref": "py-obj:kiso.schema.COMMONS_SCHEMA#/$defs/location"},
},
}
kiso.objects#
Shared dataclass types used across multiple modules.
Script#
@dataclass
class Script:
labels: list[str]
script: str
executable: str = "/bin/bash"
Field |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
— |
Labels identifying the target resources |
|
|
Yes |
— |
Script content to execute |
|
|
No |
|
Interpreter used to run the script |
Location#
@dataclass
class Location:
labels: list[str]
src: str
dst: str
Field |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
— |
Labels identifying the target resources |
|
|
Yes |
— |
Source file path |
|
|
Yes |
— |
Destination directory path |
kiso.edge#
Helpers for interacting with Chameleon Edge (ChameleonDevice) containers. All functions require the kiso[chameleon] extra.
upload#
def upload(
container: ChameleonDevice,
src: Path | str,
dst: Path | str,
user: str | None = None,
) -> CommandResult
Upload a file or directory to a Chameleon Edge container. Directories are uploaded file-by-file to work around API timeout limits.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Target container |
|
|
— |
Local source path |
|
|
— |
Remote destination directory |
|
|
|
Set as owner of uploaded files (defaults to root) |
Raises ValueError if src does not exist or dst is not an accessible directory.
download#
def download(
container: ChameleonDevice,
src: Path | str,
dst: Path | str,
) -> CommandResult
Download a file or directory from a Chameleon Edge container. Directories are downloaded file-by-file to work around API timeout limits.
Parameter |
Type |
Description |
|---|---|---|
|
|
Source container |
|
|
Remote source path |
|
|
Local destination directory |
Raises ValueError if dst is not an accessible local directory.
execute#
def execute(
container: ChameleonDevice,
command: Path | str,
*args: str,
workdir: Path | str | None = None,
timeout: int = 180,
poll_interval: int = 1,
user: str | None = None,
) -> CommandResult
Execute a command on a Chameleon Edge container. The command is wrapped so that stdout, stderr, and the exit code are captured via temporary files. Kiso polls for completion rather than blocking.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Target container |
|
|
— |
Command to execute |
|
|
— |
Additional arguments passed to the command |
|
|
|
Working directory |
|
|
|
Maximum seconds to wait; |
|
|
|
Seconds between completion checks |
|
|
|
Run command as this user (defaults to root) |
Returns a CommandResult. result.rc is -1 and result.status is STATUS_TIMEOUT when the command does not finish within timeout.
run_script#
def run_script(
container: ChameleonDevice,
script: Path,
*args: str,
workdir: str | None = None,
user: str | None = None,
timeout: int = 180,
poll_interval: int = 1,
task_name: str | None = None,
) -> CommandResult
Upload a script to a container, make it executable, run it, and remove it.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Target container |
|
|
— |
Local path to the script file |
|
|
— |
Arguments passed to the script |
|
|
|
Working directory on the container |
|
|
|
Run script as this user |
|
|
|
Maximum seconds to wait |
|
|
|
Seconds between completion checks |
|
|
|
Label included in the returned |
expanduser#
def expanduser(container: ChameleonDevice, path: str | Path) -> str | Path
Expand a ~-prefixed path to an absolute path by querying the container shell. Paths that do not start with ~ are returned unchanged. The return type matches the input type.
Parameter |
Type |
Description |
|---|---|---|
|
|
Container to query |
|
|
Path to expand |
command_result#
def command_result(
container: ChameleonDevice,
status: dict[str, Any],
task_name: str | None,
) -> CommandResult
Convert a raw Zun API response dict into an EnOSlib CommandResult.
Key in |
Description |
|---|---|
|
Integer exit code, or |
|
Combined stdout text from the container |
kiso.ip#
Functions for associating public IP addresses with nodes across testbeds.
associate_floating_ip#
def associate_floating_ip(node: Host | ChameleonDevice) -> IPv4Address | IPv6Address
Attach a public IP address to a node. The strategy is determined by node.extra["kind"].
|
Strategy |
|---|---|
|
Reuses an existing floating IP or creates a new one via the OpenStack CLI |
|
Reads |
|
Creates an |
|
Always raises |
The acquired IP is appended to node.extra["floating-ips"].
Raises ValueError for an unknown kind or a provider-level error. Raises KisoError for Vagrant nodes.
kiso.errors#
Exception hierarchy raised by Kiso.
Class |
Base |
Description |
|---|---|---|
|
|
Base class for all Kiso exceptions |
|
|
Invalid value in configuration or execution |
|
|
An operation exceeded its allowed time limit |
See also#
How extensions work — how to write plugins that use these APIs
CLI reference — command-line interface
Config file reference — all supported config keys